Issue
The Git plugin for Jenkins allows pruning stale tags.
When I add (and save) such an option through the Jenkins dashboard:
The configuration change is the following:
When the build runs, this option is ignored. Why the option is set to false instead of true?
Jenkins version: 2.222.4
Jenkins Git plugin version: 4.6.0
Solution
That seems a bug to be reported to the git-plugin
Jira.
The pipeline form (which is tested by the plugin) would be:
node {
checkout([ $class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [pruneTags(true)],
submoduleCfg: [],
userRemoteConfigs: [[url: 'remoteURL']]
])"
}
But if you are not using pipelines and relying on the classic GUI, pruneTags (boolean pruneTags)
is never called.
Since the code has not changed for the past 2 years, it could be a side-effect of your version of Jenkins 2.x.
Still, I would first upgrade the plugin to the latest 4.10.1, for testing.
However, The OP Marc points out in the comments to their issue JENKINS-67473: "Git plugin does not add pruneTags from UI".
That was closed as too hard to reproduce reliably (with Jenkins 2.319.1 and git plugin 4.10.1.).
Steps I took to try to duplicate the problem:
- Create a freestyle project using git SCM and include the "prune stale tags" setting
- Run the job and confirm that the "Pruning obsolete local tags that do not exist on remotes" message is included in the log
- Create a different freestyle project using git SCM with the JGit implementation instead of command line git and include the "prune stale tags" setting
- Run the job and confirm that the "Pruning obsolete local tags that do not exist on remotes" message is included in the log
- Confirm that the XML definitions of the jobs include
pruneStaleTags
set totrue
Since there have been multiple security advisories published for Jenkins core since 2.222.4 and multiple security advisories for the git plugin, I recommend upgrading to see if it resolves the issue.
Answered By - VonC
Answer Checked By - Senaida (JavaFixing Volunteer)