I recently moved a freestyle Jenkins job to (multibranch) pipeline, and discovered that there was a subtle change in behaviour in the checkout being made. Before:
git fetch --tags --force --progress -- git@github.com:*** +refs/heads/*:refs/remotes/origin/* # timeout=10
And after:
git fetch --no-tags --force --progress -- https://github.com/*** +refs/heads/master:refs/remotes/origin/master # timeout=10
The important difference here being the --no-tags
. This is probably a sensible default for most use cases (i.e. a faster clone), but this job was using semantic-release; which needs the tags.
It’s relatively simple to fix this in the ui, you can add an “advanced clone behaviours” block, and tick a box:
But this job is created using the Job DSL, and I couldn’t see any easy way to add that to the branchSource
. In the end, I changed the checkout step from:
stage('Checkout') {
steps {
checkout scm
}
}
to:
checkout scmGit(
branches: scm.branches,
extensions: [cloneOption(noTags: false, reference: '', shallow: false)],
userRemoteConfigs: scm.userRemoteConfigs
)