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

Git plug-in & included regions : build not triggered in case of mutiple commits in one push.

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: git-plugin
    • Labels:
    • Environment:
      Debian
    • Similar Issues:

      Description

      I've been testing the Included regions feature for GitSCM plugin
      via SCM polling and Git hook.

      We are building only one branch : master.

      I could see that in some cases the jobs were not triggered whereas
      some changes have been made in files matching the included regions pattern.

      After some more testing I discovered that if several commits are made
      and pushed at the same time, only changes from the last commit is taken into account.

      Spying the git command the plugin is using I could see :

      git rev-parse --verify HEAD
      git command : fetch -t https://url.git +refs/heads/*:refs/remotes/
      origin/*
      git tag -l master
      git command : rev-parse origin/master^

      {commit}

      -> Gives the new SHA1
      git command : show --no-abbrev --format=raw -M --raw 'new sha1'

      The last command shows only diff from latest commit, should't it be
      something like :

      git show --no-abbrev --format=raw -M --raw 'old sha1'..'new sha1'

      'old sha1' being the sha1 of the latest build.

      I had a look at the source code of the git plugin and tried a patch.

      With the correction, the problem is not reproduced in my use case
      where I build only one branch.

      I put the patch as attachment.

      Jenkins 1.456
      Git Plugin 1.1.16

        Attachments

          Activity

          Hide
          blatinville Bertrand Latinville added a comment -

          I've been using this correction for more than one month and I
          did not detect any problems related to included regions.
          The patch could be improved anyway by searching differences compared to the last
          fetch and not the last build.

          Show
          blatinville Bertrand Latinville added a comment - I've been using this correction for more than one month and I did not detect any problems related to included regions. The patch could be improved anyway by searching differences compared to the last fetch and not the last build.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: David Tanner
          Path:
          src/main/java/hudson/plugins/git/GitAPI.java
          src/main/java/hudson/plugins/git/GitSCM.java
          src/main/java/hudson/plugins/git/IGitAPI.java
          http://jenkins-ci.org/commit/git-plugin/8e139916a2937df84f06706bef85e5635c8f2e5f
          Log:
          JENKINS-13368 Merging in change as suggested. Also added a little null
          checking for the buildData being passed around now.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: David Tanner Path: src/main/java/hudson/plugins/git/GitAPI.java src/main/java/hudson/plugins/git/GitSCM.java src/main/java/hudson/plugins/git/IGitAPI.java http://jenkins-ci.org/commit/git-plugin/8e139916a2937df84f06706bef85e5635c8f2e5f Log: JENKINS-13368 Merging in change as suggested. Also added a little null checking for the buildData being passed around now.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: David Tanner
          Path:
          src/main/java/hudson/plugins/git/GitAPI.java
          http://jenkins-ci.org/commit/git-plugin/2bf5f34cb6679ad25ba1a873da3600ba2cd38181
          Log:
          JENKINS-13368 Changing SHA1 of last build to
          buildData.lastBuild.revision.getSha1String().

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: David Tanner Path: src/main/java/hudson/plugins/git/GitAPI.java http://jenkins-ci.org/commit/git-plugin/2bf5f34cb6679ad25ba1a873da3600ba2cd38181 Log: JENKINS-13368 Changing SHA1 of last build to buildData.lastBuild.revision.getSha1String().
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: David Tanner
          Path:
          src/main/java/hudson/plugins/git/GitAPI.java
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/f160f6f1472516695e9116ee5d8a83d0a668a0e8
          Log:
          [FIXED JENKINS-13368] Fixed GitAPI so it does both the older style of
          checking for changed
          files, and used the recommended change. Added test case for commits to
          included files that were changed further back than the last commit.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: David Tanner Path: src/main/java/hudson/plugins/git/GitAPI.java src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/f160f6f1472516695e9116ee5d8a83d0a668a0e8 Log: [FIXED JENKINS-13368] Fixed GitAPI so it does both the older style of checking for changed files, and used the recommended change. Added test case for commits to included files that were changed further back than the last commit.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: David Tanner
          Path:
          src/main/java/hudson/plugins/git/GitAPI.java
          http://jenkins-ci.org/commit/git-plugin/7a302e70d19339f992bf730dfaa095373c00fe7f
          Log:
          [FIXED JENKINS-13368] Added one more level of null pointer checking for
          new code.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: David Tanner Path: src/main/java/hudson/plugins/git/GitAPI.java http://jenkins-ci.org/commit/git-plugin/7a302e70d19339f992bf730dfaa095373c00fe7f Log: [FIXED JENKINS-13368] Added one more level of null pointer checking for new code.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Nicolas De loof
          Path:
          src/main/java/hudson/plugins/git/GitAPI.java
          src/main/java/hudson/plugins/git/GitSCM.java
          src/main/java/hudson/plugins/git/IGitAPI.java
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/513d89b4a8a90980e23c02cce35cbdbc2ed069d0
          Log:
          Merge pull request #106 from darthtanner/master

          JENKINS-13368 Fix for missing changes if multiple commits back.

          Compare: https://github.com/jenkinsci/git-plugin/compare/cb2e9c911b59...513d89b4a8a9

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De loof Path: src/main/java/hudson/plugins/git/GitAPI.java src/main/java/hudson/plugins/git/GitSCM.java src/main/java/hudson/plugins/git/IGitAPI.java src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/513d89b4a8a90980e23c02cce35cbdbc2ed069d0 Log: Merge pull request #106 from darthtanner/master JENKINS-13368 Fix for missing changes if multiple commits back. Compare: https://github.com/jenkinsci/git-plugin/compare/cb2e9c911b59...513d89b4a8a9

            People

            • Assignee:
              ndeloof Nicolas De Loof
              Reporter:
              blatinville Bertrand Latinville
            • Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: