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

Git polling builds same branch multiple times when 'Execute concurrent builds if necessary' turned on

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      We have a job setup to build pull request branches based on a naming convention on the branches. The branch specifier is /pr/. We have 'Execute concurrent builds if necessary' turned on for this job and sometimes Jenkins will kick off 4-5 builds for the same branch at the same time and fill up the executors. I've tried adding a quiet period but that didn't seem to help.

        Attachments

          Issue Links

            Activity

            Hide
            exodus Oleksandr Chyrkov added a comment -

            Hi there. I use git-plugin 2.3.5 and this issue exists.
            Job starts a few times.
            I fetch changes from repo from branch with slashes(feature/test). And after this job execution job starts few times and doesn't find any changes.
            I know that branches with slashes it is another Jenkins issue but job starts a few times anyway.

            Show
            exodus Oleksandr Chyrkov added a comment - Hi there. I use git-plugin 2.3.5 and this issue exists. Job starts a few times. I fetch changes from repo from branch with slashes(feature/test). And after this job execution job starts few times and doesn't find any changes. I know that branches with slashes it is another Jenkins issue but job starts a few times anyway.
            Hide
            cbennett Colin Bennett added a comment -

            I confirm the existence of this bug. Apparently since the Git plugin is looking only at the last completed build's Git commit hash, concurrent builds are not identified.

            The solution is probably to implement something like the Groovy script Jeff Skjonsby posted above, except implement it in the Git plugin directly. If manually triggered, we might actually want to rebuild the same commit twice concurrently (different parameters? want to compare consistency of test runs?) but for polling we would only expect to fire up a single build for a particular commit.

            Show
            cbennett Colin Bennett added a comment - I confirm the existence of this bug. Apparently since the Git plugin is looking only at the last completed build's Git commit hash, concurrent builds are not identified. The solution is probably to implement something like the Groovy script Jeff Skjonsby posted above, except implement it in the Git plugin directly. If manually triggered, we might actually want to rebuild the same commit twice concurrently (different parameters? want to compare consistency of test runs?) but for polling we would only expect to fire up a single build for a particular commit.
            Hide
            cbennett Colin Bennett added a comment -

            The bug still exists with Git plugin v2.4.4 and Jenkins v1.642.3.

            I can see why it exists, since if the last built commit is X, and then Y is committed, a build is triggered for commit Y and the last build data in Jenkins is for X. But if polling happens again (in my case due to a GitLab web hook posting to Jenkins) then a second concurrent build will be started for commit Y, since the last completed build was for X.

            Show
            cbennett Colin Bennett added a comment - The bug still exists with Git plugin v2.4.4 and Jenkins v1.642.3. I can see why it exists, since if the last built commit is X, and then Y is committed, a build is triggered for commit Y and the last build data in Jenkins is for X. But if polling happens again (in my case due to a GitLab web hook posting to Jenkins) then a second concurrent build will be started for commit Y, since the last completed build was for X.
            Hide
            vassilevsky Ilya Vassilevsky added a comment -

            I don't know Java very well. Is this the place where a new build is scheduled to run?

            https://github.com/jenkinsci/git-plugin/blob/f6ace83fe36740a1ab35612d3b4c5b400647f6ea/src/main/java/hudson/plugins/git/GitSCM.java#L1001

            Is this method the right place to check for existing running builds?

            Show
            vassilevsky Ilya Vassilevsky added a comment - I don't know Java very well. Is this the place where a new build is scheduled to run? https://github.com/jenkinsci/git-plugin/blob/f6ace83fe36740a1ab35612d3b4c5b400647f6ea/src/main/java/hudson/plugins/git/GitSCM.java#L1001 Is this method the right place to check for existing running builds?
            Hide
            jglick Jesse Glick added a comment -

            Use multibranch projects and you will not suffer from this kind of problem.

            Show
            jglick Jesse Glick added a comment - Use multibranch projects and you will not suffer from this kind of problem.

              People

              • Assignee:
                Unassigned
                Reporter:
                jskjons Jeff Skjonsby
              • Votes:
                10 Vote for this issue
                Watchers:
                18 Start watching this issue

                Dates

                • Created:
                  Updated: