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

Git plugin dev version 2.3.6-0c1a59a8 builds on every poll

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • git-plugin
    • None

      A change introduced since the release of git plugin 2.3.5 has caused the plugin to start a new build each time the git server is polled for changes. It does not do that for every job, and I'm not clear why it does it for this specific job definition, but I've confirmed several times that this configuration has the problem, and that it did not have the problem with 2.3.5 and earlier.

      Steps to duplicate the problem:

      1. Clone a docker repo with the base config on a branch
        git clone https://github.com/MarkEWaite/docker.git
        
      2. checkout the docker branch to show the problem
        cd docker
        git checkout -b master-JENKINS-26179-poll-now-always-starts-a-build -t origin/master-JENKINS-26179-poll-now-always-starts-a-build
        
      3. Build the docker image
        sudo docker build -t markewaite/JENKINS-26179 .
        
      4. Run the docker image
        sudo docker run -p 9090:8080 -p 50000:50000 -i -t markewaite/JENKINS-26179
        
      5. Create the job
        java -jar jenkins-cli-jar -s http://localhost:9090 create-job JENKINS-26179 < JENKINS-26179.xml
        
      6. Poll for changes so the job will build - Confirm that it builds 5 times (once for each branch)
      7. Press "Poll Now" - Confirm that (as expected) it does not build again
      8. Install git plugin pre-release 2.3.6
      9. Restart Jenkins (to activate the enw git plugin version)
      10. Press "Poll Now" - Confirm that (unexpected - the bug) it builds each time "Poll Now" is pressed

          [JENKINS-29066] Git plugin dev version 2.3.6-0c1a59a8 builds on every poll

          Mark Waite added a comment -

          Refer to the updated docker repo for more details on how to duplicate the problem for both JGit and command line git.

          Mark Waite added a comment - Refer to the updated docker repo for more details on how to duplicate the problem for both JGit and command line git.

          I was able to reproduce and diagnose this issue.
          This issue occurs as the remote repo as some branch which is ancestor for another one. On https://github.com/MarkEWaite/JENKINS-26197 you're using to reproduce this issue : master is ancestor for branch-2015-06-10-21-21-21-pe

          As the job is built first, all `branch-*` branches get built as expected and master is excluded as hudson.plugins.git.util.GitUtils#filterTipBranches is excluding such non-tip branches. Then during polling (without workspace) master branch is detected as a non-built head, a build is triggered for it, and checkout do exclude it again and do re-build previous commit, resulting in infinite build loop.

          I can't find a reasonable workaround for this issue. I propose to introduce a new "FilterTipBranches" advanced behavior to enable hudson.plugins.git.util.GitUtils#filterTipBranches, This one would force use of a workspace for polling, and would be automatically added to any pre-2.3.6 job.
          wdyt ?

          Nicolas De Loof added a comment - I was able to reproduce and diagnose this issue. This issue occurs as the remote repo as some branch which is ancestor for another one. On https://github.com/MarkEWaite/JENKINS-26197 you're using to reproduce this issue : master is ancestor for branch-2015-06-10-21-21-21-pe As the job is built first, all `branch-*` branches get built as expected and master is excluded as hudson.plugins.git.util.GitUtils#filterTipBranches is excluding such non-tip branches. Then during polling (without workspace) master branch is detected as a non-built head, a build is triggered for it, and checkout do exclude it again and do re-build previous commit, resulting in infinite build loop. I can't find a reasonable workaround for this issue. I propose to introduce a new "FilterTipBranches" advanced behavior to enable hudson.plugins.git.util.GitUtils#filterTipBranches, This one would force use of a workspace for polling, and would be automatically added to any pre-2.3.6 job. wdyt ?

          maybe safer to revert this remote-polling stuff and get 2.3.6 released

          Nicolas De Loof added a comment - maybe safer to revert this remote-polling stuff and get 2.3.6 released

          proposed to revert on https://github.com/jenkinsci/git-plugin/pull/331
          introduce a test to prevent such a regression in future

          will investigate further use of ls-remote in a separate branch

          Nicolas De Loof added a comment - proposed to revert on https://github.com/jenkinsci/git-plugin/pull/331 introduce a test to prevent such a regression in future will investigate further use of ls-remote in a separate branch

          Mark Waite added a comment -

          I just checked that proposed pull request and confirmed that it resolves the problem.

          Mark Waite added a comment - I just checked that proposed pull request and confirmed that it resolves the problem.

          Code changed in jenkins
          User: Nicolas De Loof
          Path:
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/199f5e8b175d134942b2b8415f299d52ed92e756
          Log:
          JENKINS-29066 reproduction testcate

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/199f5e8b175d134942b2b8415f299d52ed92e756 Log: JENKINS-29066 reproduction testcate

          Code changed in jenkins
          User: Nicolas De Loof
          Path:
          src/main/java/hudson/plugins/git/GitSCM.java
          http://jenkins-ci.org/commit/git-plugin/e5c75f18c4d68d55bc9950f006ff76b4092eb933
          Log:
          [FIX JENKINS-29066] Revert "Can poll without workspace"

          This reverts commit ccd4efa756c6cac3db5072e28cd84c9763d56c50.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: src/main/java/hudson/plugins/git/GitSCM.java http://jenkins-ci.org/commit/git-plugin/e5c75f18c4d68d55bc9950f006ff76b4092eb933 Log: [FIX JENKINS-29066] Revert "Can poll without workspace" This reverts commit ccd4efa756c6cac3db5072e28cd84c9763d56c50.

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/06dc97fb8264d85aa45b9c2f880e6bfe74f03c20
          Log:
          Test polling of parent of HEAD commit with and without workspace

          More testing of JENKINS-29066

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/06dc97fb8264d85aa45b9c2f880e6bfe74f03c20 Log: Test polling of parent of HEAD commit with and without workspace More testing of JENKINS-29066

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/main/java/hudson/plugins/git/GitSCM.java
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/3745d562fcad08cda294eaf9bc56e9c8840463f3
          Log:
          Merge pull request #331 from ndeloof/JENKINS-29066

          JENKINS-29066 potential fix

          Compare: https://github.com/jenkinsci/git-plugin/compare/e051c3273aaa...3745d562fcad

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/main/java/hudson/plugins/git/GitSCM.java src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/3745d562fcad08cda294eaf9bc56e9c8840463f3 Log: Merge pull request #331 from ndeloof/ JENKINS-29066 JENKINS-29066 potential fix Compare: https://github.com/jenkinsci/git-plugin/compare/e051c3273aaa...3745d562fcad

          Mark Waite added a comment -

          Fix included in git plugin 2.4.0 released 18 July 2015

          Mark Waite added a comment - Fix included in git plugin 2.4.0 released 18 July 2015

            markewaite Mark Waite
            markewaite Mark Waite
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: