From bcc33a76cb7245fd806430712b10b3d7dbc5d6bf Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Thu, 30 Sep 2021 15:04:13 +0200 Subject: [PATCH] Cancel old pipeline runs if a new commit arrives before the old build finishes --- Jenkinsfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index e5db903889..ef3f147763 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,6 +16,14 @@ import org.hibernate.jenkins.pipeline.helpers.job.JobHelper @Field final String NODE_PATTERN_BASE = 'Worker&&Containers' @Field List 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 {