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

Git Polling Jobs with Included Regions being triggered unnecessarily with merge commits

    XMLWordPrintable

Details

    Description

      We have a single Git repository with several projects in a directory structure. I have created build jobs with polling enabled for each project and have included the appropriate directory structure in the "Included Regions" option in the git plugin setup. I have also turned on "Force Polling using Workspace" as indicated in https://issues.jenkins-ci.org/browse/JENKINS-20569.

      We are using a git-flow type development process, and the jobs are all configured to watch the '*/dev' branch. All commits made to this branch are merges. It appears that whenever a merge commit is made, it will trigger all of the jobs, regardless of if the merge only contained changes to one of the projects' directories.

      I looked into the polling log and it looks like the way that the plugin is getting the commit log and checking the paths may be causing the issue. Here is the command that the job runs in the polling log:

      > /usr/bin/git log --full-history --no-abbrev --format=raw -M -m --raw ff0ec94a066cee23c13faa16b38b247911cd5ee7..f47993565f701a4f28174c4ea81f35d0e1103590

      If I run this command manually, I can see that the returned paths for each commit also includes paths from other commits. I'm not sure why this is, but from the 'git' documentation, it looks like the '-m' parameter will do a full diff on both parents of a merge commit. If I leave off the '-m' parameter, or if I include '--first-parent', the list of paths in the commits only shows the actual affected files made by the commit which triggered the job. Perhaps this option needs to be included in the job config?

      Attachments

        Issue Links

          Activity

            kshultz Karl Shultz added a comment -

            tmar (and others) - here's a question about the issues you're experiencing with included and excluded regions. Are you, by chance, starting your included regions with a leading /, as lledhub alluded to in this comment from September 9, 2016?

            I've written eight new tests that look at included/excluded areas specifically with merge commits. It took me a really, really long time to see it, but eventually I realized that the last failing test was failing because it had committed directory/filename to the git repository, but the included/excluded region pattern was looking for /directory/filename. The difference was that leading slash.

            kshultz Karl Shultz added a comment - tmar (and others) - here's a question about the issues you're experiencing with included and excluded regions. Are you, by chance, starting your included regions with a leading / , as lledhub alluded to in this comment from September 9, 2016? I've written eight new tests that look at included/excluded areas specifically with merge commits. It took me a really, really long time to see it, but eventually I realized that the last failing test was failing because it had committed directory/filename to the git repository, but the included/excluded region pattern was looking for /directory/filename . The difference was that leading slash.
            kshultz Karl Shultz added a comment - - edited

            The eight new tests have been merged to master. They include, in the form of "top level directory of the repo" and "inside a subdirectory" tests, the following:

            • Merge commits inside of excluded regions get ignored (file, directory)
            • Merge commits inside of included regions get processed as new changes (file, directory)
            • Merge commits outside of included regions get ignored (file, directory)
            • Merge commits outside of excluded regions get processed (file, directory)
            kshultz Karl Shultz added a comment - - edited The eight new tests have been merged to master . They include, in the form of "top level directory of the repo" and "inside a subdirectory" tests, the following: Merge commits inside of excluded regions get ignored ( file , directory ) Merge commits inside of included regions get processed as new changes ( file , directory ) Merge commits outside of included regions get ignored ( file , directory ) Merge commits outside of excluded regions get processed ( file , directory )
            tmar Tomasz M added a comment -

            kshultz - here are the settings we use:

            Branch Specifier (blank for 'any') :origin/develop
            Included Regions ^report-service/.*
            Excluded Regions [empty]  
            tmar Tomasz M added a comment - kshultz - here are the settings we use: Branch Specifier (blank for 'any') :origin/develop Included Regions ^report-service/.* Excluded Regions [empty]  

            We have the same issue: https://issues.jenkins.io/browse/JENKINS-65932
            Indeed the command with '-m'
            ```
            git log --full-history --no-abbrev --format=raw --raw -M -m 9aa631d36264e7d21e60881265572ec099ebc2b1..4fa8bc728c0a83d8defd2fb8a786505c1fbca7be
            ```
            contains invalid commit history included foreign changes from merge request

            How to disable '-m' flag in polling?

            anatolys Anatoly Shirokov added a comment - We have the same issue: https://issues.jenkins.io/browse/JENKINS-65932 Indeed the command with '-m' ``` git log --full-history --no-abbrev --format=raw --raw -M -m 9aa631d36264e7d21e60881265572ec099ebc2b1..4fa8bc728c0a83d8defd2fb8a786505c1fbca7be ``` contains invalid commit history included foreign changes from merge request How to disable '-m' flag in polling?
            anatolys Anatoly Shirokov added a comment - It seems to me here is fix https://github.com/jenkinsci/git-client-plugin/pull/750

            People

              Unassigned Unassigned
              tduskin Trey Duskin
              Votes:
              27 Vote for this issue
              Watchers:
              31 Start watching this issue

              Dates

                Created:
                Updated: