I've inherited a truly ancient Jenkins server that needed a rebuild from the OS up, and I'm at the point of migrating our builds over. However there's one multibranch pipeline in particular with dozens of feature/bugfix/etc branches and builds that take significant amounts of time and resources. When I initially set up its multibranch pipeline on the test cluster the initial builds of all the branches monopolized all the resources for hours until I killed them.
What I would like to happen is have all the branches initially imported but not built until there's another push or PR for the branch. Currently I've applied the "Suppress automatic SCM triggering" strategy defined, but as soon as I remove it Jenkins attempts to build all branches.
What I think may be a viable solution would be to set the status on each branch to something other than 'Not Built', and then remove the suppression strategy.
I've run across the below Groovy script that will change the result of a particular build, but it seems to require that there actually be a previous build to change the status of.
import com.cloudbees.groovy.cps.NonCPS
import jenkins.model.*
import hudson.model.Result
@NonCPS
def getProject(projectName) {
// CloudBees folder plugin is supported, you can use natural paths:
// in a postbuild action use `manager.hudson`
// in the script web console use `Jenkins.instance`
def project = jenkins.model.Jenkins.instance.getItemByFullName(projectName)
if (!project) {error("Project not found: $projectName")}
return project
}
project = getProject('foo/bar')
build = project.getBuildByNumber(2443)
// build = project.getBuild(project, '2443')
build.@result = hudson.model.Result.SUCCESS
// build.@result = hudson.model.Result.NOT_BUILT
// build.@result = hudson.model.Result.UNSTABLE
// build.@result = hudson.model.Result.FAILURE
// build.@result = hudson.model.Result.ABORTED
Source: https://stackoverflow.com/a/45708131/1064767
Is there a way to change the status of the project itself, or a way to create a "dummy" build with a particular status?