Cancel old pipeline runs if a new commit arrives before the old build finishes

This commit is contained in:
Christian Beikov 2021-09-30 15:04:13 +02:00
parent cef7988528
commit bcc33a76cb
1 changed files with 8 additions and 0 deletions

8
Jenkinsfile vendored
View File

@ -16,6 +16,14 @@ import org.hibernate.jenkins.pipeline.helpers.job.JobHelper
@Field final String NODE_PATTERN_BASE = 'Worker&&Containers'
@Field List<BuildEnvironment> environments
// Cancel previous runs automatically by reaching milestones
// See https://issues.jenkins.io/browse/JENKINS-43353
def buildNumber = BUILD_NUMBER as int;
if (buildNumber > 1) {
milestone(buildNumber - 1)
}
milestone(buildNumber)
this.helper = new JobHelper(this)
helper.runWithNotification {