2

How do I access the current date as a macro in Jenkins?

enter image description here

Caused by: org.jenkinsci.plugins.tokenmacro.MacroEvaluationException: Unrecognized macro 'BUILD_TIMESTAMP' in 'sprint5-${BUILD_TIMESTAMP}'

${DATE} didn't work either. Nothing in the glossary about macro. https://jenkins.io/doc/book/glossary/

No useful search results. https://duckduckgo.com/?q=jenkins+date+macro&ia=web

Chloe
  • 25,162
  • 40
  • 190
  • 357
  • The title is about all macros, but the question only asks for build timestamp. Please clarify, for future searches. – handras Jan 31 '19 at 16:07
  • 1
    @handras If I find a list of all macros I can search for the date macro. (Or find there is no such thing.) Also I may want to use a different macro later. It would be a good reference. – Chloe Jan 31 '19 at 20:18

2 Answers2

3

You find all available environment variables here, on Jenkins wiki. Other plugins may define additional macros.

handras
  • 1,548
  • 14
  • 28
  • Due to SEO of the title of this question, this was actually the answer I needed despite the content of the OP question. Thank you! – Josh Peak Nov 24 '20 at 00:19
1

You can check all default environment variables on http://<JENKINS_IP>:<JENKINS_PORT>/env-vars.html or from official page.
By default there is no time environment variable. Previously it could be possible to use ${BUILD_ID}, but now it is identical to ${BUILD_NUMBER} for builds created in 1.597+ Jenkins.

For using ${BUILD_TIMESTAMP} environment variable in your job, you need to install (and configure) Build Timestamp Plugin.

Note: I cannot check if you can use that plugin in Version Label Format step exactly, so probably you can also look at Zentimestamp Plugin.

biruk1230
  • 3,042
  • 4
  • 16
  • 29