Issue
On a controller running in High Availability (HA) mode, updating a job’s next build number through the Script Console or the /scriptText endpoint (for example, with job.updateNextBuildNumber(100)) only takes effect on the replica that handled the request.
Other replicas keep the previous value, so new builds may not use the expected build number.
Environment
-
Cloudbees CI on modern cloud platforms - managed controller running in High Availability (active/active) mode
Explanation
Script Console and /scriptText scripts run only on the replica that receives the request, and changes made with Job.updateNextBuildNumber() are not replicated to other replicas.
Jenkins has no supported feature for setting an arbitrary build number at runtime. Build numbers are assigned automatically and sequentially to uniquely identify builds.
Resolution
This is expected behavior. If you need to trace a specific build, for example during a job migration, use the full build URL instead of a manually set build number.
Workaround
If you must change the next build number, for example for a one-time import:
-
Stop the controller.
-
Edit the
$JENKINS_HOME/jobs/<job-path>/nextBuildNumberfile and set the desired value. -
Start the controller.
-
Trigger a build and confirm it uses the expected build number.
| Make sure the controller is fully stopped before editing the file. |
Tested product/plugin versions
-
Cloudbees CI on modern cloud platforms - managed controller - 2.541.3.36069-rolling