How can I display build timestamps for each line of a multi-branch pipeline project? Is it a supported feature? If yes, does it need to be enabled in the Jenkinsfile
or is there a GUI option?
3 Answers
Adding options to the declarative pipeline
pipeline {
agent any
options { timestamps () }
// stages and rest of pipeline.
}
Credit goes to the comment above Jenkins Pipeline: Enable timestamps in build log console
-
2I actually find this more useful than just timestamping specific code blocks. Feb 20, 2020 at 8:06
-
1@RaúlSalinas-Monteagudo yeah its really useful only for declarative pipelines, not for scripted pipelines Mar 9, 2021 at 20:39
-
2Doesn't work for me:
WorkflowScript: 3: Invalid option type "timestamps". Valid option types [ansiColor, buildDiscarder,...]
Oct 20, 2021 at 19:23 -
@ChrisWolf, late to the party you are probably missing the Timestamper plugin Dec 22, 2021 at 19:26
-
For scripted pipeline just wrap your script in timestamps { }
Eg.
timestamps {
// do your job
}
Note: You must have the timestamper plugin installed: wiki.jenkins.io/display/JENKINS/Timestamper
-
12I just noticed that (at least in our setup) you can configure this globally: check the "Enabled for all Pipeline builds" in the "Timestamper" section in Jenkins configuration– roomsgJul 10, 2019 at 12:36
-
1The option mentioned by @roomsg can be found under
<jenkins_url>/configure
Nov 23, 2020 at 13:23 -
I'm wondering why @roomsg comment on the accepted answer didn't become an answer.
I just noticed that (at least in our setup) you can configure this globally: check the "Enabled for all Pipeline builds" in the "Timestamper" section in Jenkins configuration
I think this is the best answering for Q. So,in case you have access as admin you can set it for all pipeline jobs through GUI
options { timestamps() }
below theagent
should work. I forget where I learned it, but you can see an example here. I don't know how to tell what things are supported insideoptions
buttimestamps()
is. Pretty sure you need this plugin: wiki.jenkins.io/display/JENKINS/Timestamper.options
in a scripted pipeline?script {}
sections. I'm not having any luck figuring it out with their docs either.