Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: skip build if only documentation files were changed #5610

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading