-
New Feature
-
Resolution: Fixed
-
Major
-
None
-
-
2.42
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 grayaii 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.
Manual equivalent courtesy of bsquizz:
def buildNumber = BUILD_NUMBER as int; if (buildNumber > 1) milestone(buildNumber - 1); milestone(buildNumber)
- is related to
-
JENKINS-43132 Cancel existing job if the new job is pending
-
- Resolved
-
-
JENKINS-47503 Abort ongoing builds of PR if new change to the same PR was submitted
-
- Resolved
-
- relates to
-
JENKINS-40936 Milestone should be able to abort older builds when reaching the same milestone
-
- Open
-
-
JENKINS-39180 Milestone option to coalesce queue items while awaiting executor
-
- Open
-
-
JENKINS-58625 Use milestone to cancel older builds
-
- Resolved
-
- links to
Ended up not using Milestone because it doesn't communicate the build # that was stopped. Instead we're trying to use
If we put this outside of our node blocks, things are working well. We previously had this in a node{} which was horrible, and resolved the issue after you informing me of the heavyweight vs flyweight executors.