2

After system restart where Jenkins is stored, one of the jobs is constantly failing it is trying to create bulid with number 1 but there is already 1400 past builds. Is there a way to change it so the build will be created with correct increment so in this case 1401.

Full stactrace from jenkins:

java.lang.IllegalStateException: [Directory]\builds\1 already existed; will 
not overwite with [Build.Name] #1
at hudson.model.RunMap.put(RunMap.java:189)
at jenkins.model.lazy.LazyBuildMixIn.newBuild(LazyBuildMixIn.java:178)
at hudson.model.AbstractProject.newBuild(AbstractProject.java:1011)
at hudson.model.AbstractProject.createExecutable(AbstractProject.java:1210)
at hudson.model.AbstractProject.createExecutable(AbstractProject.java:144)
at hudson.model.Executor$1.call(Executor.java:328)
at hudson.model.Executor$1.call(Executor.java:310)
at hudson.model.Queue._withLock(Queue.java:1251)
at hudson.model.Queue.withLock(Queue.java:1189)
at hudson.model.Executor.run(Executor.java:310)
vertigo448
  • 88
  • 1
  • 7

3 Answers3

4

You can use a groovy script in $JENKINS_URL/script as follows:

item = Jenkins.instance.getItemByFullName("jobName")
item.updateNextBuildNumber(1401)
OrangeDog
  • 36,653
  • 12
  • 122
  • 207
1

It looks like you can use the "Next Build Number" plugin to accomplish this: https://wiki.jenkins.io/display/JENKINS/Next+Build+Number+Plugin

loadstar81
  • 103
  • 1
  • 7
  • Yes I saw that plugin, unfortunately I cannot use any new plugin's. This is a "frozen" environment for performance tests I i cannot install anything new there I was hoping that this number (or at least increment start) is sitting somewhere in configuration file smiling at me – vertigo448 Jan 03 '18 at 21:37
0

There is a file you can edit: $JENKINS_HOME/jobs/../nextBuildNumber

$ cat /var/lib/jenkins/jobs/my-project/branches/develop/nextBuildNumber
42

You will need to reload configuration after changing it.

OrangeDog
  • 36,653
  • 12
  • 122
  • 207