Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I modify the BUILD_DISPLAY_NAME so that is the build number but zero padded?

For example, if Jenkins build number is 54, I would like the name to be 00054.

share|improve this question
Is this a Jenkins question, or was Jenkins just an example? – Dan Dec 2 '13 at 15:21
No, it is related to Jenkins. I'm comfortable zero padding numbers in programming but I'm expecting how to do the same thing using Jenkins plugins. – Veehmot Dec 2 '13 at 15:27

The Build Name setter is an option, as already reported by Peter Schuetze. Personally, I have found it a bit cumbersome, so I also use a Groovy System script (from the Groovy plugin) with the following snippet (e.g. set the build name from the Build paramters, which is not related to the actual question, I know):

def resolver = build.buildVariableResolver
share|improve this answer

Following advice from @patrice-m, I used the Scriptler plugin, and created the following script:

return String.format("%04d", Thread.currentThread().executable.getNumber());

Also, I make sure to activate both Permission and Restriction checkboxes, which will allow the script to be run by everybody, and on a Master thread (necessary to access the current build).

share|improve this answer

Use the Build Name Setter Plugin. During your build you just need to write the build number in the right format to a property file and it will be picked up when the build finishes.

share|improve this answer
So that includes manually modifying a file every time a build is done? – Veehmot Dec 3 '13 at 13:34
I wouldn't call it manual to have a buildstep that generates the file during your build. Alternative would be to create a plugin that either sets the build number for you or having a plugin that does the formatting for you by having a plugin that extends the token macro plugin. – Peter Schuetze Dec 3 '13 at 14:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.