chore(QTDI-2347): prevent concurrent builds and skip release-triggered builds in Jenkinsfile#1218
Conversation
…d builds in Jenkinsfile
There was a problem hiding this comment.
Pull request overview
Updates the Jenkins declarative pipeline to reduce build contention and avoid CI loops caused by release automation commits.
Changes:
- Disables concurrent builds for the Jenkins pipeline job.
- Adds an early stage that attempts to skip builds triggered by maven-release-plugin “prepare release” commits.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // 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')) { |
There was a problem hiding this comment.
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).
| // 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')) { | |
| // Skip builds triggered by maven-release-plugin commits (for example "prepare release" | |
| // and "prepare for next development iteration") 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]')) { |
| currentBuild.result = 'NOT_BUILT' | ||
| error("Build skipped - triggered by release process commit: ${lastCommitMsg}") |
There was a problem hiding this comment.
Setting currentBuild.result to 'NOT_BUILT' and then calling error(...) will still throw an exception that is treated as a build failure unless it is caught/handled. If the intent is a cleanly skipped build (not a failed one) for SCM/status checks, wrap the abort in catchError(buildResult: 'NOT_BUILT', stageResult: 'NOT_BUILT') (or an equivalent pattern) and avoid leaving the build in a FAILURE state.
| 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}") | |
| } |
https://qlik-dev.atlassian.net/browse/QTDI-2347