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.
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.
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.
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
build.setDisplayName(build.displayName+"_"+resolver.resolve("BUILD_TYPE"))
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).