1

With DSL I can do something like:

bnumber = build.environment.get("BUILD_NUMBER")
build("Compile.Net", BUILD_NUMBER: bnumber)

which is great. It seems to set the BUILD_NUMBER var of the downstream job. However the display name is still with the incremented automatically number and also if I manually start the job after, it will have incremented build number from the wrong one (not the one that has been passed as a parameter). I guess there is another action needed as a shell script or something to set the BUILD_NUMBER and Displayname and save it incremented in the configuration as nextBuildNumber file. Perhaps this PlugIn could help:

https://wiki.jenkins-ci.org/display/JENKINS/Next+Build+Number+Plugin

The question is if there is a better way of doing it or I should continue to work in the same direction? Is there a better way of setting the build number of a downstream job to be the same as the build flow job?

daspilker
  • 8,154
  • 1
  • 35
  • 49
vezenkov
  • 4,009
  • 1
  • 26
  • 27
  • In newer versions of Jenkins build numbers are used to store build results for a particular job (check /jenkins/jobs/{jobname}). If a build number is forcefully overwritten you may effectively lose past run results triggered by your coworkers ;). This is because jobs can possibly be triggered from different parent projects or manually (making build #s out of sync). The safer solution that I've seen is to maintain references to builds rather than trying to match build numbers. – Chrizt0f Oct 27 '15 at 14:20
  • Good point. I can't agree more - just that these downstream jobs won't be started independently and I'd really like to keep same build number for easier tracking. I think I will simply use the build name setter plugin instead of changing the actual build number. Another funny stuff is the automatic promotion and discarding of downstream jobs... – vezenkov Oct 28 '15 at 18:32

0 Answers0