Skip to content

Commit

Permalink
Jenkinsfile hack for auto-cancellation.
Browse files Browse the repository at this point in the history
This change will cause Jenkins to only build the
latest HEAD of a PR branch, cancelling any
previous builds that may already be in progress.
This will decrease feedback time and help mitigate
resource contention.

Signed-off-by: Peter Salvatore <[email protected]>
  • Loading branch information
psftw committed Sep 3, 2019
1 parent f505abb commit 85bcc52
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,23 @@ pipeline {
TIMEOUT = '120m'
}
stages {
stage('pr-hack') {
when { changeRequest() }
steps {
script {
echo "Workaround for PR auto-cancel feature. Borrowed from https://issues.jenkins-ci.org/browse/JENKINS-43353"
def buildNumber = env.BUILD_NUMBER as int
if (buildNumber > 1) milestone(buildNumber - 1)
milestone(buildNumber)
}
}
}
stage('DCO-check') {
when {
beforeAgent true
expression { !params.skip_dco }
}
agent { label 'linux' }
agent { label 'amd64 && ubuntu-1804 && overlay2' }
steps {
sh '''
docker run --rm \
Expand Down

0 comments on commit 85bcc52

Please sign in to comment.