How to set the next build number in a Multibranch pipeline for a specific branch

I am trying to set the next build number for our release branch programmatically, but I ran into a problem.

Below are two ways I tried this:

def job = Jenkins.instance.getItem("master")
job.nextBuildNumber = env.BUILD_NUMBER + 1
job.saveNextBuildNumber()

I also tried using the command CLI:

java -jar ${env.HOME} jenkins-cli.jar -s XX-JENKINS-SERVER" set-next-build-number 'Pipeline/master' 44

But no luck.

Please tell me how to configure the next assembly number for multi-unit piping.

+4
source share
3 answers

, , . , , " :" , .

StackOverflow :

Jenkins.instance.getItemByFullName("My-Build-Pipeline/feature%2FABC-9-improve-build").updateNextBuildNumber(47)

" " :

My-Build-Pipeline/feature%2FABC-9-improve-build

"Next Build Number", , .

+4

, , .

def jobName = "job-name"
def nextnumber = 32


def wfjob = Jenkins.instance.getItemByFullName(jobName)
def job = wfjob.getItem("master")
print "Was: " + job.nextBuildNumber + "\n"
job.nextBuildNumber = nextnumber
print "Now: " + job.nextBuildNumber
job.save()
wfjob.save()
0

You cannot set the next build number. This is only internal use used to distinguish between job runs. Each time you run a task, the build number is incremented by one. There is no need (and I do not recommend trying) to set the next build number.

Consider changing the description, using job.setDisplayName, to reflect what is happening with the release candidate, or perhaps baking it in the branch itself release-candidate-branch-34.

-4
source

Source: https://habr.com/ru/post/1659451/


All Articles