Hi all, I found a bug in the Jenkins Git plugin where tags are not checked out unless you clone the project twice. I filed a JIRA ticket: JENKINS-67984 with details on how to reproduce the bug but I’m not getting much traction there. I had a look at the Jenkins Git Plugin source code but I wouldn’t even know where to start in order to write an unit test. Can anyone please help me figure out what to do?
edit: I also pushed my code to GitHub so it’s straightforward for anyone to test it in their own jenkins instance.
Note this bug breaks all scm-based versioning plugins, for example: jgitver (maven/gradle), setuptools_scm (python), sbt-git-versioning (scala), which is why I marked it as Major.
Honestly though, I feel like your trying to work around a problem you shouldn’t be having in the first place.
this prevents the pipeline from checking out, and then your calling checkout manually. Is there a reason your doing this? If you enable the “Discover tags” build strategy, at least for multibranch or org scan pipelines, you should have tag information.
When you say it doesn’t check them out, what do you mean? how is it not doing it? how are you confirming its not doing it?
@halkeye in the code snippet I am disabling the default checkout to illustrate that even when you tell the git plugin to checkout tags explicitly and right after cleaning the workspace (so you know an existing repository will not be there), tags are not checked out the first time around, therefore you need two checkouts.
The default checkout just does a normal checkout scm which by default has noTags set to true (see also the related issue I linked in my issue: JENKINS-45164). This means tags are only checked out when they are being built, not when building other things (branches, PRs).
If I enable “discover tags” I will have tag information when building a tag, but not when building anything else. If I am using something like setuptools_scm or some of the other versioning plugins i mentioned in the Jira ticket, they will not work properly when not building tags, because they don’t have tag information.