build: Consolidate touched file checks

This will make it easier to add more in the future.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2022-12-15 16:44:20 +00:00
parent 2f855c9a67
commit 0031dacd7b

39
Jenkinsfile vendored
View File

@ -10,29 +10,16 @@ pipeline {
checkout scm checkout scm
} }
} }
stage('Check for documentation only changes') { stage('Check if worker build can be skipped') {
when { when {
expression { expression {
return docsFileOnly() return skipWorkerBuild()
} }
} }
steps { steps {
script { script {
runWorkers = false runWorkers = false
echo 'Documentation only changes, no need to run the CI' echo 'No changes requring a build'
}
}
}
stage('Check for fuzzer files only changes') {
when {
expression {
return fuzzFileOnly()
}
}
steps {
script {
runWorkers = false
echo 'Fuzzer cargo files only changes, no need to run the CI'
} }
} }
} }
@ -432,24 +419,24 @@ def installAzureCli(distro, arch) {
sh 'sudo apt install -y azure-cli' sh 'sudo apt install -y azure-cli'
} }
def boolean docsFileOnly() { def boolean skipWorkerBuild() {
if (env.CHANGE_TARGET == null) { if (env.CHANGE_TARGET == null) {
return false return false
} }
return sh( if (sh(
returnStatus: true, returnStatus: true,
script: "git diff --name-only origin/${env.CHANGE_TARGET}... | grep -v '\\.md'" script: "git diff --name-only origin/${env.CHANGE_TARGET}... | grep -v '\\.md'"
) != 0 ) != 0) {
} return true
def boolean fuzzFileOnly() {
if (env.CHANGE_TARGET == null) {
return false
} }
return sh( if (sh(
returnStatus: true, returnStatus: true,
script: "git diff --name-only origin/${env.CHANGE_TARGET}... | grep -v -E 'fuzz/'" script: "git diff --name-only origin/${env.CHANGE_TARGET}... | grep -v -E 'fuzz/'"
) != 0 ) != 0) {
return true
}
return false
} }