Skip to content

Commit 7d0026e

Browse files
committed
Abort previous builds when PR has a new commit
1 parent 6bcd564 commit 7d0026e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Jenkinsfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ pipeline {
99
// stages are ordered according to execution time; highest time first
1010
// nodes are selected based on a priority (in Jenkins config)
1111
stages {
12+
stage('abort running builds') {
13+
/* If this is a change request, cancel previous builds if you push a new commit */
14+
when {
15+
changeRequest()
16+
}
17+
steps {
18+
script {
19+
def buildNumber = env.BUILD_NUMBER as int
20+
if (buildNumber > 1) milestone(buildNumber - 1)
21+
milestone(buildNumber)
22+
}
23+
}
24+
}
1225
stage('setup') {
1326
parallel {
1427
stage('gcc') {

0 commit comments

Comments
 (0)