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

Git Plugin Polling Not Picking Up New Changes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • git-plugin
    • None
    • Jenkins version: 2.47, ​OS Git version: 2.7.4, Git plugin version: 3.0.5, Git client plugin version: 2.2.1​, and ​SCM API plugin version: 2.0.7​

      For some reason my Jenkins instance stopped picking up new Git changes when polling. I think it had to do with the updates for the latest plugins. Also the Jenkins instance is running directly on the OS.

      Here's the job details for SCM:

      ​Repo URL: git@github.com:SimpTek-Technologies/Foo.git​
      ​Repository Name: origin
      Refspec: +refs/heads/develop:refs/remotes/origin/develop​
      ​Branches to build: refs/remotes/origin/develop​
      ​Additional Behaviours:

      • Checkout to specific local branch: (left value blank as it will be develop)
      • Clean before checkout
      • Force polling using workspace (HAD TO DO THIS TO GET AROUND BUG)​

      ​I had to use force polling using workspace to get the poller to work. The git ls-remote does work correctly when running through a Bash shell session. It looks like the plugin isn't comparing the last build SHA1 value with the latest in Git.​

      ​Here's the command details from the Bash shell session:

      jenkins@jenkins:/var/lib/jenkins/workspace/Develop/Clients/Foo$ git ls-remote -h git@github.com:SimpTek-Technologies/Foo.git # timeout=10
      b6f141a367aa42e0d8262aa35fbe20fba314eb94	refs/heads/develop
      ffb74a8f55cef31aac3d3f7f3ac4b82a49138a4b	refs/heads/master
      3ee8a4ac718aa441d289ede5e005f93a3be742a7	refs/heads/staging​
      

      ​Here's the polling log of the last build where it shows that the plugin isn't correctly comparing the new SHA1 value (b6f141a367aa42e0d8262aa35fbe20fba314eb94) with the old:

      ​Started on 23-Feb-2017 12:06:47 PM
      Using strategy: Default
      [poll] Last Built Revision: Revision dab5696b067c87cb9a0e9196a7fb522a88a14f7b (refs/remotes/origin/develop)
      using GIT_SSH to set credentials SimpTek GitHub credentials
       > git ls-remote -h git@github.com:SimpTek-Technologies/Foo.git # timeout=10
      Found 3 remote heads on git@github.com:SimpTek-Technologies/Foo.git
      Ignoring refs/heads/master as it doesn't match any of the configured refspecs
      Ignoring refs/heads/staging as it doesn't match any of the configured refspecs
      Done. Took 0.66 sec
      No changes​
      

      ​Here's when I ran the git log command on the branch in the workspace for that repo on Jenkins:​

      ​commit dab5696b067c87cb9a0e9196a7fb522a88a14f7b
      Author: Colin McQueen
      Date:   Tue Feb 21 10:15:44 2017 -0400
      
          Testing webhook.​
      

      ​Here's the polling log with the force polling on the workspace:​

      ​Started on 23-Feb-2017 12:11:38 PM
      Polling SCM changes on master
      Using strategy: Default
      [poll] Last Built Revision: Revision dab5696b067c87cb9a0e9196a7fb522a88a14f7b (refs/remotes/origin/develop)
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repositories
       > git config remote.origin.url git@github.com:SimpTek-Technologies/Foo.git # timeout=10
      Cleaning workspace
       > git rev-parse --verify HEAD # timeout=10
      Resetting working tree
       > git reset --hard # timeout=10
       > git clean -fdx # timeout=10
      Fetching upstream changes from git@github.com:SimpTek-Technologies/Foo.git
       > git --version # timeout=10
      using GIT_SSH to set credentials SimpTek GitHub credentials
       > git fetch --tags --progress git@github.com:SimpTek-Technologies/Foo.git +refs/heads/develop:refs/remotes/origin/develop
      Polling for changes in
       > git rev-parse refs/remotes/origin/develop^{commit} # timeout=10
       > git rev-parse refs/remotes/origin/refs/remotes/origin/develop^{commit} # timeout=10
       > git log --full-history --no-abbrev --format=raw -M -m dab5696b067c87cb9a0e9196a7fb522a88a14f7b..b6f141a367aa42e0d8262aa35fbe20fba314eb94 # timeout=10
      Done. Took 0.68 sec
      Changes found​
      

      ​As shown above for some reason it says "Polling SCM changes on master" even though no changes happened on master and only the develop branch. I'm assuming this is hardcoded in the code to say master.

      The fix for this should be to compare the previous SHA1 value with the new SHA1 value from git ls remote. If there is a difference then a build would be kicked off.

            Unassigned Unassigned
            colinmc Colin McQueen
            Votes:
            12 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: