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?

- 12,249
- 13
- 87
- 142
-
32`options { timestamps() }` below the `agent` should work. I forget where I learned it, but you can see an example [here](https://stackoverflow.com/questions/42956598/how-to-set-job-properties-for-jobs-within-a-jenkins-multi-branch-pipeline-projec/42961160#42961160). I don't know how to tell what things are supported inside `options` but `timestamps()` is. Pretty sure you need this plugin: https://wiki.jenkins.io/display/JENKINS/Timestamper. – Quantic Oct 31 '17 at 19:20
-
1@Quantic Can I use `options` in a scripted pipeline? – lanoxx Nov 07 '17 at 15:08
-
Oh, I don't know. I use declarative with a couple `script {}` sections. I'm not having any luck figuring it out with their docs either. – Quantic Nov 07 '17 at 23:32
-
That link isn't working. https://plugins.jenkins.io/timestamper/ – nroose Sep 11 '21 at 04:55
4 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

- 1,815
- 2
- 22
- 25
-
2I actually find this more useful than just timestamping specific code blocks. – Raúl Salinas-Monteagudo Feb 20 '20 at 08:06
-
1@RaúlSalinas-Monteagudo yeah its really useful only for declarative pipelines, not for scripted pipelines – Yor Jaggy Mar 09 '21 at 20:39
-
2Doesn't work for me: `WorkflowScript: 3: Invalid option type "timestamps". Valid option types [ansiColor, buildDiscarder,...]` – Chris Wolf Oct 20 '21 at 19:23
-
1@ChrisWolf, late to the party you are probably missing the Timestamper plugin – wiredniko Dec 22 '21 at 19:26
-
-
@wiredniko - thanks, but unfortunately forced to use a version of Jenkins too old for the `Timestamper` plugin. :( – Chris Wolf Mar 04 '22 at 23:07
-
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

- 1,026
- 2
- 10
- 27

- 2,276
- 2
- 21
- 30
-
13I 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 – roomsg Jul 10 '19 at 12:36
-
2The option mentioned by @roomsg can be found under `
/configure` – Marcello Romani Nov 23 '20 at 13:23 -
That link isn't working. How about https://plugins.jenkins.io/timestamper/ – nroose Sep 11 '21 at 04:54
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

- 428
- 11
- 22
To enable Timestamper globally (all builds):
- Go to the Jenkins configuration
- Go to the "Timestamper" configration
-> Select the "Enabled for all Pipeline builds" checkbox.

- 3,593
- 30
- 34