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
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.
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.
Comments
4 comments
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.
JFYI, using getItem() you'd need to do (for the same result of course):
job = Jenkins.getItem("my-folder-name").getItem("my-job-name")
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.
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.
Please sign in to leave a comment.