How to set next build number in Pipeline job? Bee Bot July 13, 2022 11:40 Updated The content of this article has moved to the new documentation site. Related articles How to set build name in Pipeline job? How to set current build result in Pipeline? How can I associate artifact versions with a specific Jenkins build? Get Build Number with REST API How to Trigger Multibranch Jobs from Bitbucket Server? Comments 4 comments Sort by Date Votes Ed Meagher March 27, 2016 20:08 Edited My jobs are in folders and in order to change the build number on them I did the following: job = Jenkins.getInstance().getItemByFullName("my-folder-name/my-job-name", Job.class) job.nextBuildNumber = 92 job.save() I'm not sure why the 'getItem(jobname)' wouldn't find the job even when I specified the folder. 0 James Morgan November 18, 2016 14:28 JFYI, using getItem() you'd need to do (for the same result of course):job = Jenkins.getItem("my-folder-name").getItem("my-job-name") 0 Steven Christou November 21, 2016 16:02 Hello James and Ed, I updated the article to use getItemByFullName. The getItem method only will search at the top level of a project, however if you have items in any subfolders (2* levels) it will not search. Thanks, Steve. 1 Derrik Ammons June 07, 2017 20:36 I couldn't get this to work in my scenario. Will this work if the build has already been kicked off from a multibranch pipeline script? I want to reset the build back to 1 if the version is greater than the previous version. I posted a Jira ticket for Jenkins: https://issues.jenkins-ci.org/browse/JENKINS-44757. 0 Please sign in to leave a comment.