-
Bug
-
Resolution: Unresolved
-
Minor
-
Jenkins 1.565
Git Client Plugin 1.8.1
Git Plugin 2.2.1
I have a job I changed to build from a tag. However, I'd left the polling enabled. I noticed that the job built every time that it polled. The polling log shows:
Started on Jun 3, 2014 7:20:00 PM
Using strategy: Default
[poll] Last Built Revision: Revision aacfd8d1828633ccfb7ced255e795a29e31d6228 (mytag)
> git ls-remote -h git@hostname:my/project mytag
Done. Took 0.39 sec
Changes found
I noticed that the ls-remote command is being passed "-h", which I believe is causing the issue. The -h would exclude tags. Thus:
$ git ls-remote -h git@hostname:my/project mytag
Yields no results, but removing the "-h":
$ git ls-remote git@hostname:my/project mytag
aacfd8d1828633ccfb7ced255e795a29e31d6228 refs/tags/mytag
Code changed in jenkins
User: Mark Waite
Path:
src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java
http://jenkins-ci.org/commit/git-client-plugin/4362cf66b19519a558984d33f7e4272131087b6a
Log:
[Fix JENKINS-23299] tag based builds run at every poll
When a build is defined to use a tag, the "check for changes" uses
ls-remote to compare the SHA1 of the remote tag to the SHA1 of the HEAD
of the working directory. The tag SHA1 is not always the same as the
commit SHA1 (annotated tags), so when that happens, the ls-remote based
"check for changes" can never be satisfied.
This change adapts the tag specific check for changes to use a syntax
which returns the SHA1 of the commit referenced by the tag rather than
the SHA1 of the tag.
JGit always returns the SHA1 of the commit referenced by a tag (a
"peeled" object), while CliGit returns a "peeled" object for tags only
if the refs/tags/tag_name syntax is used.
That difference is maintained for behavioral compatibility for users
of CliGit. Cases where returning the SHA1 of the tag would be better
than returning the SHA1 of the commit referenced by the tag seem rare,
but better to retain CliGit compatibility than risk surprising users in
some as yet undetected use case.