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

JGit incorrectly reports changes detected when polling

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Trivial Trivial
    • git-plugin
    • None
    • Windows and Linux slaves running Jenkins 1.509.4, Git plugin 2.0, Git client plugin 1.4.5

      A Jenkins job configured with the Git plugin using the JGit implementation will execute the job at each polling interval, even when there were no changes on the git repository.

      The same job, configured with the Git plugin using the git command line implementation only executes the job when there were changes in the git repository.

      The problem is visible with both a git protocol repository and with a GitHub repository using the https protocol.

      Sample job definitions which show the problem are attached. The job definitions with "jgit" in the XML file name show the problem. The job definitions with "cli" in the XML file name do not show the problem.

      There is a simple work around for the problem. Add the "Force polling using workspace" to the job configuration through the "Additional Behaviours" section of the git plugin configuration for the job. That avoids the problem "ls-remote" in the JGit plugin implementation. Unfortunately, it also slows the polling process in those cases where the repository does not already exist

      Another work around is to remove wildcards from the branch name in the job definition. Unfortunately, that removes the ability to monitor multiple branches with a single Jenkins job.

          [JENKINS-20286] JGit incorrectly reports changes detected when polling

          Mark Waite added a comment -

          Another work around that may help for some is to define the "Branches to build" explicitly as a single branch name in the terms of the remote (for example, "master" rather than "*/master" or "origin/master"). It appears that the JGit implementation of the ls-remote command does not perform the same matching of wildcards as the CliGit implementation

          Mark Waite added a comment - Another work around that may help for some is to define the "Branches to build" explicitly as a single branch name in the terms of the remote (for example, "master" rather than "*/master" or "origin/master"). It appears that the JGit implementation of the ls-remote command does not perform the same matching of wildcards as the CliGit implementation

          Mark Waite added a comment -

          A test has been submitted to my fork of the git-client-plugin repository which shows that the getHeadRev behavior is different between JGit and CliGit implementations when a wildcard is included in either the repository name or the branch name.

          No fix yet, just a test that confirms the difference in behavior.

          Mark Waite added a comment - A test has been submitted to my fork of the git-client-plugin repository which shows that the getHeadRev behavior is different between JGit and CliGit implementations when a wildcard is included in either the repository name or the branch name. No fix yet, just a test that confirms the difference in behavior.

          Mark Waite added a comment -

          Mark Waite added a comment - Pull request https://github.com/jenkinsci/git-client-plugin/pull/94 has been submitted

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java
          src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java
          http://jenkins-ci.org/commit/git-client-plugin/b9f2b5a2db8b028960f6cff27848aa769196aa05
          Log:
          [FIXED JENKINS-20286] JGit rebuilds on each poll if wildcard in branch name

          The JGit implementation of getHeadRev did not process filename wildcards,
          while the CliGit implementation did. That caused JGit polling of remote
          repositories (with the JGit form of "git ls-remote") to always report
          there were changes if the branch name included a wildcard, even when
          there were no changes.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java http://jenkins-ci.org/commit/git-client-plugin/b9f2b5a2db8b028960f6cff27848aa769196aa05 Log: [FIXED JENKINS-20286] JGit rebuilds on each poll if wildcard in branch name The JGit implementation of getHeadRev did not process filename wildcards, while the CliGit implementation did. That caused JGit polling of remote repositories (with the JGit form of "git ls-remote") to always report there were changes if the branch name included a wildcard, even when there were no changes.

          Code changed in jenkins
          User: Nicolas De loof
          Path:
          src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java
          src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java
          http://jenkins-ci.org/commit/git-client-plugin/77f75f24bfb8e3ce1d0b04cfa27ebe117cc2bb0e
          Log:
          Merge pull request #94 from MarkEWaite/master-fix-JGit-getHeadRev-wildcard-matching

          [FIXED JENKINS-20286] JGit rebuilds on each poll if wildcard in branch n...

          Compare: https://github.com/jenkinsci/git-client-plugin/compare/dd56a77c525f...77f75f24bfb8

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De loof Path: src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java http://jenkins-ci.org/commit/git-client-plugin/77f75f24bfb8e3ce1d0b04cfa27ebe117cc2bb0e Log: Merge pull request #94 from MarkEWaite/master-fix-JGit-getHeadRev-wildcard-matching [FIXED JENKINS-20286] JGit rebuilds on each poll if wildcard in branch n... Compare: https://github.com/jenkinsci/git-client-plugin/compare/dd56a77c525f...77f75f24bfb8

          Mark Waite added a comment -

          Confirmed fixed in git-client-plugin 1.6.2

          Mark Waite added a comment - Confirmed fixed in git-client-plugin 1.6.2

            ndeloof Nicolas De Loof
            markewaite Mark Waite
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: