Is there a way to make Jenkins automatically detect the latest build from 
the history and automatically update the nextBuildNumber file? 

We are using the "jenkins.model.Jenkins.buildsDir" system property 
<https://www.jenkins.io/doc/book/managing/system-properties/> to separate 
jobs/ from builds/. When provisioning a new staging environment for our 
jenkins controller, we restore the build history from the production 
controller by rsyncing their buildsDirs. 

On restart of the fresh new staging controller, the GUI for each job page 
correctly shows the build history, but the nextBuildNumber files are not 
updated correctly, and remain in their initial state. Because these 
indicate the next build number to be 1, when I click Build, nothing 
happens, and an error is logged in /var/log/jenkins/jenkins.log indicating 
that build number 1 already exists and it cannot overwrite. The 
nextBuildNumber file gets incremented, and next time it complains about 
build 2 existing, and so forth. So, presumably this will happen until next 
build number gets up to the 1 past the most recent build in the history 
that was rsynced over from production.

Are we going to have to script a solution, or is there a way to make 
Jenkins automatically detect the latest build from the history and 
automatically update the nextBuildNumber file?

We're using Jenkins CasC to manage all jenkins configuration, and the above 
system tries to implement a solution for backing up and restoring build 
history, to provide build history continuity across promotions of jenkins 
clusters across dev/test/staging/prod environments.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/b2d6a04a-1ff4-47dc-ac63-698b540e827bn%40googlegroups.com.

Reply via email to