Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-23299

Project building from tag builds at each polling interval

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • git-plugin
    • 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

          [JENKINS-23299] Project building from tag builds at each polling interval

          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.

          SCM/JIRA link daemon added a comment - 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.

          Mark Waite added a comment -

          Fixed in git-client-plugin 1.10.2, released 12 Sep 2014

          Mark Waite added a comment - Fixed in git-client-plugin 1.10.2, released 12 Sep 2014

          Code changed in jenkins
          User: Mark Waite
          Path:
          pom.xml
          http://jenkins-ci.org/commit/git-plugin/4682d5ede81be35da32026c5a1e2124d59c230e3
          Log:
          Revert "Depend on git-client 1.10.2" until test failure fixed

          This reverts commit 87beb7d0270c3058c90fd178b0aa96049ad6a900 until
          the automated test which fails in the code can be fixed. The test is
          specifically noted that it is an area of bugs in the prior client plugin,
          and the fix of JENKINS-23299 in git client plugin 1.10.2 has improved
          the behavior, but the test needs to be updated to show the new behavior
          (and have its TODO comment removed).

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: pom.xml http://jenkins-ci.org/commit/git-plugin/4682d5ede81be35da32026c5a1e2124d59c230e3 Log: Revert "Depend on git-client 1.10.2" until test failure fixed This reverts commit 87beb7d0270c3058c90fd178b0aa96049ad6a900 until the automated test which fails in the code can be fixed. The test is specifically noted that it is an area of bugs in the prior client plugin, and the fix of JENKINS-23299 in git client plugin 1.10.2 has improved the behavior, but the test needs to be updated to show the new behavior (and have its TODO comment removed).

          Code changed in jenkins
          User: Mark Waite
          Path:
          pom.xml
          http://jenkins-ci.org/commit/git-plugin/8add48556e33f1bbb1595402086644863e0bbb63
          Log:
          Revert "Update git-client dependency to 1.10.2"

          This reverts prior commit until the automated test which fails in the
          code can be fixed. The test is specifically noted that it is an area
          of bugs in the prior client plugin. The fix of JENKINS-23299 in git
          client plugin 1.10.2 has improved the behavior, but the test needs to
          be updated to show the new behavior (and have its TODO comment removed).

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: pom.xml http://jenkins-ci.org/commit/git-plugin/8add48556e33f1bbb1595402086644863e0bbb63 Log: Revert "Update git-client dependency to 1.10.2" This reverts prior commit until the automated test which fails in the code can be fixed. The test is specifically noted that it is an area of bugs in the prior client plugin. The fix of JENKINS-23299 in git client plugin 1.10.2 has improved the behavior, but the test needs to be updated to show the new behavior (and have its TODO comment removed).

          Code changed in jenkins
          User: Mark Waite
          Path:
          pom.xml
          src/test/java/hudson/plugins/git/CliGitSCMTriggerRemotePollTest.java
          http://jenkins-ci.org/commit/git-plugin/f654185b384a67b4e107f86d52b1ff2797c616d0
          Log:
          Adapt tests for JENKINS-23299 fix and git-client-plugin 1.10.2

          Intentionally skip one test, enable another

          Depend on git-client-plugin 1.10.2

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: pom.xml src/test/java/hudson/plugins/git/CliGitSCMTriggerRemotePollTest.java http://jenkins-ci.org/commit/git-plugin/f654185b384a67b4e107f86d52b1ff2797c616d0 Log: Adapt tests for JENKINS-23299 fix and git-client-plugin 1.10.2 Intentionally skip one test, enable another Depend on git-client-plugin 1.10.2

          Code changed in jenkins
          User: Mark Waite
          Path:
          pom.xml
          src/test/java/hudson/plugins/git/CliGitSCMTriggerRemotePollTest.java
          http://jenkins-ci.org/commit/git-plugin/12351a2ef8dc726144ae5e6234f0e240fc4a5977
          Log:
          Adapt tests for JENKINS-23299 fix and git-client-plugin 1.10.2

          Intentionally skip one test, enable another

          Depend on git-client-plugin 1.10.2

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: pom.xml src/test/java/hudson/plugins/git/CliGitSCMTriggerRemotePollTest.java http://jenkins-ci.org/commit/git-plugin/12351a2ef8dc726144ae5e6234f0e240fc4a5977 Log: Adapt tests for JENKINS-23299 fix and git-client-plugin 1.10.2 Intentionally skip one test, enable another Depend on git-client-plugin 1.10.2

          It appears not working.
          I have Jenkins - 2.27
          Git Client Plugin - 2.0.0
          Git Plugin - 3.0.0

          Project configured to build from "refs/tags/ci-qa"
          But polling is still running with '-h'.
          As result build is not initiated when revision of tag is changed.

          Alexey Ostrovsky added a comment - It appears not working. I have Jenkins - 2.27 Git Client Plugin - 2.0.0 Git Plugin - 3.0.0 Project configured to build from "refs/tags/ci-qa" But polling is still running with '-h'. As result build is not initiated when revision of tag is changed.

          Peter Jones added a comment -

          +1
          I have same request and am hitting same limitation where I cannot trigger a build just from a tag change (non-annotated tag).

          Will the use of annotated tags get around this limitation ?

          Peter Jones added a comment - +1 I have same request and am hitting same limitation where I cannot trigger a build just from a tag change (non-annotated tag). Will the use of annotated tags get around this limitation ?

          Are there any plans to fix that small but annoying bug?

          Alexey Ostrovsky added a comment - Are there any plans to fix that small but annoying bug?

          Mark Waite added a comment -

          progman No plans to fix this bug at this time. You're welcome to submit a pull request with automated tests which show the problem, and with a fix for the problem.

          Mark Waite added a comment - progman No plans to fix this bug at this time. You're welcome to submit a pull request with automated tests which show the problem, and with a fix for the problem.

            Unassigned Unassigned
            drwille Daniel Wille
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: