-
Notifications
You must be signed in to change notification settings - Fork 51
chore(QTDI-2347): prevent concurrent builds and skip release-triggered builds in Jenkinsfile #1218
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -109,6 +109,7 @@ pipeline { | |||||||||||
| buildDiscarder(logRotator(artifactNumToKeepStr: '10', numToKeepStr: branch_name == 'master' ? '15' : '10')) | ||||||||||||
| timeout(time: 180, unit: 'MINUTES') | ||||||||||||
| skipStagesAfterUnstable() | ||||||||||||
| disableConcurrentBuilds() | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| triggers { | ||||||||||||
|
|
@@ -243,6 +244,21 @@ pipeline { | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| stages { | ||||||||||||
| stage('Check skip build') { | ||||||||||||
| steps { | ||||||||||||
| script { | ||||||||||||
| // Skip builds triggered by maven-release-plugin commits (e.g. "prepare release") to avoid infinite loop of builds during the release process. | ||||||||||||
| // These commits are part of the release process and should not trigger a new CI build | ||||||||||||
| def lastCommitMsg = sh(script: 'git --no-pager log -1 --pretty=%s', returnStdout: true).trim() | ||||||||||||
| if (lastCommitMsg.startsWith('[maven-release-plugin] prepare release')) { | ||||||||||||
| echo "Skipping build triggered by release commit: ${lastCommitMsg}" | ||||||||||||
| currentBuild.description = "Skipped: release commit" | ||||||||||||
| currentBuild.result = 'NOT_BUILT' | ||||||||||||
| error("Build skipped - triggered by release process commit: ${lastCommitMsg}") | ||||||||||||
|
Comment on lines
+256
to
+257
|
||||||||||||
| currentBuild.result = 'NOT_BUILT' | |
| error("Build skipped - triggered by release process commit: ${lastCommitMsg}") | |
| catchError(buildResult: 'NOT_BUILT', stageResult: 'NOT_BUILT') { | |
| error("Build skipped - triggered by release process commit: ${lastCommitMsg}") | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says we want to skip builds triggered by maven-release-plugin commits, but the condition only matches the specific prefix "[maven-release-plugin] prepare release". Maven release typically also creates a "prepare for next development iteration" commit (and potentially other maven-release-plugin messages), which will still trigger CI and defeat the stated goal. Consider matching on the common "[maven-release-plugin]" prefix and/or including the other release-plugin commit messages in the check (e.g., via regex).