Skip to content

Commit

Permalink
ci: skip build if only documentation files were changed (#5610)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdibi authored and MMaiero committed Dec 19, 2024
1 parent fe2f5f6 commit 13f5c68
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
def boolean onlyDocumentationFilesChangedIn(String workDirectory) {
if (!env.CHANGE_TARGET) {
echo "CHANGE_TARGET not set. Skipping check"
return false
}

def changedFiles = sh(script: "cd ${workDirectory} && git diff --name-only origin/${env.CHANGE_TARGET} origin/${env.BRANCH_NAME}", returnStdout: true).trim().split("\n")

echo "Changed files: ${changedFiles}" // Debug

return changedFiles && changedFiles.every { it.endsWith(".md") || it.endsWith(".txt") }
}

node {
properties([
disableConcurrentBuilds(abortPrevious: true),
Expand All @@ -15,6 +28,13 @@ node {
}
}

// Skip build if only documentation files (i.e. *.md and *.txt) have changed
if (onlyDocumentationFilesChangedIn("kura")) {
echo "Skipping build for documentation changes"
currentBuild.result = 'SUCCESS'
return
}

stage('Build') {
timeout(time: 2, unit: 'HOURS') {
dir("kura") {
Expand Down

0 comments on commit 13f5c68

Please sign in to comment.