I have a multibranch pipeline which monitors a repository of hundreds to thousands of branches.
Each job under this multibranch pipeline does NOT require a full checkout, and a single branch checkout is preferred (a full checkout slows down the job by quite a bit).
The Jenkinsfile for this job is stored in Jenkins "Managed Files" section. I have modified this Jenkinsfile such that only a subset of branches should be checked out on job run:
...
checkout([
$class: 'GitSCM',
branches: [[name: JOB_NAME.minus('foo/')],
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: scm.extensions,
userRemoteConfigs: scm.userRemoteConfigs
])
...
However this setting is not honored. When a new build is triggered for one of the branches a full discover/checkout is performed in the job. This happens with "Build Now" and "Rebuild".
If I make use of a the "Replay" functionality on a given job however I am first presented with the correctly updated Jenkinsfile and running that replay performs the above checkout correctly (i.e. one branch).
How do I get this (a single branch checkout as specified in the Jenkinsfile) to always happen?
I have tried:
- Deleting and recreating the job (as stored as DSL)
- Manually updating the multibranch pipeline configuration
- Deleting all FS XML as it related to previous "Managed Files" version on the Jenkins master
- Jenkins restarts
I would expect that the Jenkinfile setting would be honored, however a full checkout is always performed.