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

Ability to abort all previous running builds

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      It is sometimes desirable for a job (such as a branch project) to simply abort any previously running builds as soon as a new build starts. For example, in a branch project for a pull request, you might want to see test results from an earlier commit even after pushing follow-up commits, but most of the time you only care about the results of the PR head, and computer time might be too valuable to waste on the older ones.

      (I think gerrit-trigger does something like this automatically, and I have seen Alex Gray invent the same kind of pattern with JenkinsPy.)

      Merely setting the job to not be concurrent-capable does not suffice, since then newer builds will queue up waiting for the older ones to finish.

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            Yes that is exactly the use case listed in this issue’s description.

            (Pipeline builds do not generally sit in the queue, pending JENKINS-39180.)

            Show
            jglick Jesse Glick added a comment - Yes that is exactly the use case listed in this issue’s description. (Pipeline builds do not generally sit in the queue, pending JENKINS-39180 .)
            Show
            nickbrown Nicholas Brown added a comment - This would form an effective solution for: https://issues.jenkins-ci.org/browse/JENKINS-47503 https://issues.jenkins-ci.org/browse/JENKINS-43132
            Hide
            bsquizz Brandon Squizzato added a comment - - edited

            Jesse Glick's solution worked well for me until recently, when passing milestones started to take awhile. Passing the milestones used to happen very quickly but now for whatever reason it takes a second or so to pass each milestone. When your build number is 100+, obviously this can cause a big delay trying to pass each milestone created in the loop.

            So I've started to go with an approach like this:

            def buildNumber = env.BUILD_NUMBER as int
            if (buildNumber > 1) milestone(buildNumber - 1)
            milestone(buildNumber)

            The result here would be:
            Build 1 runs and creates milestone 1
            While build 1 is running, build 2 fires. It has milestone 1 and milestone 2

            Since build 2 passes milestone 1, it causes build #1 to abort.

             

            Show
            bsquizz Brandon Squizzato added a comment - - edited Jesse Glick 's solution worked well for me until recently, when passing milestones started to take awhile. Passing the milestones used to happen very quickly but now for whatever reason it takes a second or so to pass each milestone. When your build number is 100+, obviously this can cause a big delay trying to pass each milestone created in the loop. So I've started to go with an approach like this: def buildNumber = env.BUILD_NUMBER as int if (buildNumber > 1) milestone(buildNumber - 1) milestone(buildNumber) The result here would be: Build 1 runs and creates milestone 1 While build 1 is running, build 2 fires. It has milestone 1 and milestone 2 Since build 2 passes milestone 1, it causes build #1 to abort.  
            Hide
            jglick Jesse Glick added a comment -

            Yes, this step is not going to be efficient when there are a lot of milestones. I filed PR 19 to record your suggestion.

            Show
            jglick Jesse Glick added a comment - Yes, this step is not going to be efficient when there are a lot of milestones. I filed PR 19 to record your suggestion.
            Hide
            xistence Bert JW Regeer added a comment -

            Brandon Squizzato thanks for that solution, we are up to build number 900 and passing all of the milestones while pretty fast is not the fastest, this should help

            Show
            xistence Bert JW Regeer added a comment - Brandon Squizzato thanks for that solution, we are up to build number 900 and passing all of the milestones while pretty fast is not the fastest, this should help

              People

              • Assignee:
                amuniz Antonio Muñiz
                Reporter:
                jglick Jesse Glick
              • Votes:
                6 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                • Created:
                  Updated: