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

Merge commits trigger uneccessary builds when Include/Exclude regions are defined

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • git-plugin
    • None
    • Jenkins 1.537, Jenkins GIT plugin 2.0, Jenkins GIT client plugin 1.4.6, Windows Server 2012 Standard, msysgit 1.8.4

    Description

      The "Included Regions" patterns seem to be matched against the file diff list of both parents of a merge commit instead of just the files being modified by the commits being merged in to the branch being monitored. This results in builds being triggered by every merge into the monitored branch from any branches that stem from before a commit on the monitored branch that modifies something in the "Included Regions".

      I have included a screenshot of a Git history that will hopefully help support or clarify the described situation. The order of events that occurred for this history view:

      • Jenkins job A configured to build when the autobuild/test.txt file is modified in the branch Jenkins_Testing ("Included Regions" value set to "autobuild/test\.txt")
      • branch Jenkins_Testing starts at commit 746d3
      • branch j_defect_01 is created at commit 746d3
      • branch j_defect_02 is created at commit 746d3
      • autobuild/test.txt file is modified in commit 6220e in j_defect_01
      • j_defect_01 merged into jenkins_testing (this creates FF merge of jenkins_testing and triggers a build of job A as expected)
      • autobuild/test.log file is modified in commit f7cb6 in j_defect_02
      • j_defect_02 is merged into jenkins_testing creating merge commit 91a02 with the two parent commits of f7cb6 and 6220e (this results in another build of job A being triggered even though commit f7cb6 being merged into jenkins_testing doesn't actually modify autobuild/test.txt and a build for the autobuild/test.txt changes in commit 6220e has already been run)

      It is quite possible that I don't have a good understanding of what is occurring here and am expecting behaviour other than what is actually intended, but with that being said I cannot figure out how to only have the build triggered the first time file modifications are introduced by a commit that affect files in the "Included Regions" configured for a monitored branch.

      Attachments

        Issue Links

          Activity

            mihalich Joe Mihalich added a comment - - edited

            I'm having the exact same issue in the 2.0 git plugin. I have to downgrade to 1.4.0 because of this bug. I can't have the entire project building every time one file changes. Please fix this ASAP.

            mihalich Joe Mihalich added a comment - - edited I'm having the exact same issue in the 2.0 git plugin. I have to downgrade to 1.4.0 because of this bug. I can't have the entire project building every time one file changes. Please fix this ASAP.

            Agree. This was supposedly fixed in JENKINS-13580 but I think that either did nothing or made it worse. I believe the command was changed to 'git whatchanged', and I've verified that if you run this manually against the old hash and the merge commit hash, you're still going to see a huge list of files that you wouldn't expect to see.

            br0ch0n Brandon Rochon added a comment - Agree. This was supposedly fixed in JENKINS-13580 but I think that either did nothing or made it worse. I believe the command was changed to 'git whatchanged', and I've verified that if you run this manually against the old hash and the merge commit hash, you're still going to see a huge list of files that you wouldn't expect to see.

            Perhaps basing changes on git diff-tree -r oldref newref would be best? I do this in a trigger hook now rather than relying upon the poller.

            br0ch0n Brandon Rochon added a comment - Perhaps basing changes on git diff-tree -r oldref newref would be best? I do this in a trigger hook now rather than relying upon the poller.
            tduskin Trey Duskin added a comment -

            Any update on this issue? Or, if anyone has a workaround, would you mind posting it here?

            tduskin Trey Duskin added a comment - Any update on this issue? Or, if anyone has a workaround, would you mind posting it here?

            I made a pull request to address the git-client portion of this issue:
            https://github.com/jenkinsci/git-client-plugin/pull/162

            git-plugin would need to be updated to use the new method if it's approved/merged.

            elsabbahyahmed Ahmed Elsabbahy added a comment - I made a pull request to address the git-client portion of this issue: https://github.com/jenkinsci/git-client-plugin/pull/162 git-plugin would need to be updated to use the new method if it's approved/merged.
            fairmonk mihai ono added a comment - - edited

            I have the same issue in git plugin v 2.7.2

            A git merge will trigger new build even if the commit was done on a different file than the one specified in the included region.

            Would be nice to have this fixed or some workaround provided

            Thank you !

            fairmonk mihai ono added a comment - - edited I have the same issue in git plugin v 2.7.2 A git merge will trigger new build even if the commit was done on a different file than the one specified in the included region. Would be nice to have this fixed or some workaround provided Thank you !

            kshultz is there any update on this? A lot of people are working with monorepos, myself included, which causes a lot of unwanted builds from this issue.

            giannissialmas Giannis Sialmas added a comment - kshultz  is there any update on this? A lot of people are working with monorepos, myself included, which causes a lot of unwanted builds from this issue.

            giannissialmas I have made pull request https://github.com/jenkinsci/git-client-plugin/pull/750 which is the first step to solve this problem.

            anatolys Anatoly Shirokov added a comment - giannissialmas I have made pull request https://github.com/jenkinsci/git-client-plugin/pull/750 which is the first step to solve this problem.

            People

              Unassigned Unassigned
              mlong072 Mike Long
              Votes:
              22 Vote for this issue
              Watchers:
              20 Start watching this issue

              Dates

                Created:
                Updated: