How to keep build number in sync between multiple jenkins master?

1,215 views
Skip to first unread message

Code

unread,
Feb 11, 2015, 10:50:47 PM2/11/15
to jenkin...@googlegroups.com
I have gearman, multiple jenkins masters, and several slaves. The infrastructure is like below:

                                                   Gearman 
                          __________________|____________________
                          |                                                                  |
              Jenkins Master 1                                          Jenkins Master 2                                         Jenkins Master 3 (Public jenkins)
       ___________|____________                           __________|__________
       |                  |                     |                          |                 |                  |
 Slave 1         Slave 2            Slave 3               Slave 4      Slave 5       Slave 6

I queue a job by sending a request to Gearman, then it decides which jenkins master should handle the job. After a job is built, jenkins will publish it to Jenkins Master 3 using Build Publisher Plugin. 

The tricky bit is, let's say I have a job name "job_test_1" on Jenkins Master 1 and Jenkins Master 2. The first time I queue a job on Gearman, it decides to forward the job to Jenkins Master 1. When it is built, the job has build number 1. After then, I queue a job again on Gearman but this time it decides to forward the job to Jenkins Master 2. When it is built, it got build number 1 since it's the first build on this Jenkins Master. When it publishes build to Jenkins Master 3, the result will overwrite build number 1 on Jenkins Master 1 because it has the same build number.

I read on a Jenkins forum and it seemed like this is by design. Is there a way to work around this problem?

Sam Gleske

unread,
Feb 12, 2015, 1:03:38 AM2/12/15
to jenkin...@googlegroups.com
Have you filed an issue in the Jenkins issue tracker?  This seems like a legitimate thing to want job numbers synchronized.

Code

unread,
Feb 12, 2015, 1:18:34 AM2/12/15
to jenkin...@googlegroups.com
No, I haven't. I found the same topic about Set custom build number and it seems like this is by design. I will add an issue on bug tracker.

Thanks!

Sam Gleske

unread,
Feb 13, 2015, 12:45:20 AM2/13/15
to jenkin...@googlegroups.com
According to the "set custom build number" link you gave, a quote from Kohsuke:

Hudson assumes that the build number is unique and monotonic. If you can
guarantee this condition for Hudson, then you can call
Job.updateNextBuildNumber() to set the next build number to the number
of your choice.

So it sounds like what you encountered was a bug because it build lives get overwritten unfortunately when synchronization happens.  I would think that the Gearman plugin should keep track of a global build number for a project and execute Job.updateNextBuildNumber() to keep the build number consistently incrementing across the cluster.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/YkU8yZckQ3Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/c87cadfb-1473-4c0d-a6db-0fabb416543a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
I prefer to encrypt my email

GPG FINGERPRINT 4096 KEY
8D8B F0E2 42D8 A068 572E
BF3C E8F7 3234 7257 E65F

https://keybase.io/samrocketman

Learn how to encrypt your email with the Email Self Defense guide:
https://emailselfdefense.fsf.org/en/

Sam Gleske

unread,
Feb 13, 2015, 12:46:07 AM2/13/15
to jenkinsci-dev
s/it build lives/builds/
Reply all
Reply to author
Forward
0 new messages