I suspect it depends on what number you're trying to make globally unique.

We wanted the software version number to be incremented automatically and we 
wanted to be able to rebuild the same version again at a later date, without 
changing the version number.  We adopted a technique of having the first job in 
the sequence of jobs increment the version number and push that incremented 
version number back to the source control system.  Downstream jobs then use 
that version number submission as their trigger to start.

The first job increments the software version number inside the build scripts, 
then submits the updated version number to the source control system after a 
successful build.

Later jobs do not increment the software version number, they just consume the 
version number that was set for us.

Our  technique doesn't address your request to increment in every job, but I 
think you might be able to use a similar technique in each of your jobs, 
increment the version number inside the job very early in the job and then 
immediately push the incremented version number to your source control system.  
There is still a race condition between the start of the Jenkins job and the 
push of the incremented version number, so there may be times when two jobs 
attempt to use the same version number.  You'll likely detect that race 
condition when one of the two jobs fails to push the change to the source 
control system because the change would conflict with a change that is already 
there.

We use the description setter plugin to make the generated version number 
visible in the job description on the build page.  That has been sufficient to 
show users the generated version number immediately, without altering the 
Jenkins job number.

If instead you want the Jenkins job number to be unique across all jobs in the 
system, then I think that will require either a plugin or changes to the 
Jenkins core.

Mark Waite



>________________________________
> From: Aaron Kushner <akush...@gmail.com>
>To: Jenkins Users <jenkinsci-users@googlegroups.com> 
>Sent: Saturday, February 11, 2012 12:46 AM
>Subject: Global Build Number
> 
>I've looked through this group and the various plugins, but haven't
>found how to create jobs that use a global build number. Instead of
>having a monotonically increasing build number for each job, I want
>the build number to increase across all products so that I can tell
>that build #900 for job build_component_A started after build #899 for
>job build_component_B.
>
>Or, if possible, have the build number set from an external source.
>
>If there isn't a way to do this currently, any suggestions for doing
>this via a plugin? Is this even possible?
>
>Thanks for any insights that you may have.
>
>
>

Reply via email to