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

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

    XMLWordPrintable

    Details

    • Similar Issues:

      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

            Hide
            pjohnsonic509 Phil Johnson added a comment -

             

            Show
            pjohnsonic509 Phil Johnson added a comment -  
            Hide
            tmar Tomasz M added a comment -

            We have the same problem. Our temporary workaround is to set "Merge strategies" to "Rebase and merge" on Bitbucket Server. After rebase current git log command seems to work properly.

             

            Maybe, as a simple fix, you could allow to customize git log command in configuration?

             

            Show
            tmar Tomasz M added a comment - We have the same problem. Our temporary workaround is to set "Merge strategies" to "Rebase and merge" on Bitbucket Server. After rebase current git log command seems to work properly.   Maybe, as a simple fix, you could allow to customize git log command in configuration?  
            Hide
            kshultz Karl Shultz added a comment -

            Tomasz M (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 dell 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.

            Show
            kshultz Karl Shultz added a comment - Tomasz M (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 dell 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.
            Hide
            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)
            Show
            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 )
            Hide
            tmar Tomasz M added a comment -

            Karl Shultz - here are the settings we use:

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

              People

              Assignee:
              kshultz Karl Shultz
              Reporter:
              tduskin Trey Duskin
              Votes:
              23 Vote for this issue
              Watchers:
              28 Start watching this issue

                Dates

                Created:
                Updated: