From c325aa32972414981f24b129f69c78082d8bde4c Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 9 Feb 2022 15:48:01 +0100 Subject: [PATCH] Jenkinsfile: Filter out pull requests containing only documentation No need to run the Jenkins CI on pull request for which exclusively markdown files have been modified. Signed-off-by: Sebastien Boeuf --- Jenkinsfile | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1038abd99..b307946a5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,9 +1,28 @@ +def runWorkers = true pipeline{ agent none stages { stage ('Early checks') { agent { node { label 'built-in' } } stages { + stage ('Checkout') { + steps { + checkout scm + } + } + stage ('Check for documentation only changes') { + when { + expression { + return docsFileOnly() + } + } + steps { + script { + runWorkers = false + echo "Documentation only changes, no need to run the CI" + } + } + } stage ('Check for RFC/WIP builds') { when { changeRequest comparator: 'REGEXP', title: '.*(rfc|RFC|wip|WIP).*' @@ -25,6 +44,12 @@ pipeline{ parallel { stage ('Worker build') { agent { node { label 'hirsute' } } + when { + beforeAgent true + expression { + return runWorkers + } + } stages { stage ('Checkout') { steps { @@ -55,6 +80,12 @@ pipeline{ } stage ('AArch64 worker build') { agent { node { label 'bionic-arm64' } } + when { + beforeAgent true + expression { + return runWorkers + } + } stages { stage ('Checkout') { steps { @@ -85,6 +116,12 @@ pipeline{ } stage ('Worker build (musl)') { agent { node { label 'hirsute' } } + when { + beforeAgent true + expression { + return runWorkers + } + } stages { stage ('Checkout') { steps { @@ -112,7 +149,12 @@ pipeline{ agent { node { label 'bionic-sgx' } } when { beforeAgent true - branch 'main' + allOf { + branch 'main' + expression { + return runWorkers + } + } } stages { stage ('Checkout') { @@ -148,7 +190,12 @@ pipeline{ agent { node { label 'bionic-vfio' } } when { beforeAgent true - branch 'main' + allOf { + branch 'main' + expression { + return runWorkers + } + } } stages { stage ('Checkout') { @@ -182,6 +229,12 @@ pipeline{ } stage ('Worker build - Windows guest') { agent { node { label 'hirsute' } } + when { + beforeAgent true + expression { + return runWorkers + } + } environment { AZURE_CONNECTION_STRING = credentials('46b4e7d6-315f-4cc1-8333-b58780863b9b') } @@ -222,6 +275,12 @@ pipeline{ } stage ('Worker build - Live Migration') { agent { node { label 'hirsute-small' } } + when { + beforeAgent true + expression { + return runWorkers + } + } stages { stage ('Checkout') { steps { @@ -291,3 +350,14 @@ def installAzureCli() { sh "sudo apt update" sh "sudo apt install -y azure-cli" } + +def boolean docsFileOnly() { + if (env.CHANGE_TARGET == null) { + return false; + } + + return sh( + returnStatus: true, + script: "git diff --name-only origin/${env.CHANGE_TARGET}... | grep -v '\\.md'" + ) != 0 +} \ No newline at end of file