一種解決方法,如果使用GIT:
當碰撞的版本和提交,在使用特定的消息提交日誌例如:[GIT-版本凸點] - 植球的版本
SCM後簽出,檢查最後一次提交是否爲版本緩衝提交,如果是,則中止作業。
stage('Checkout') {
checkout scm
if (lastCommitIsBumpCommit()) {
currentBuild.result = 'ABORTED'
error('Last commit bumped the version, aborting the build to prevent a loop.')
} else {
echo('Last commit is not a bump commit, job continues as normal.')
}
}
private boolean lastCommitIsBumpCommit() {
lastCommit = sh([script: 'git log -1', returnStdout: true])
if (lastCommit.contains("[git-version-bump]")) {
return true
} else {
return false
}
}
還不是一個確切的解決方案,但如果它幫助別人,我發現了兩種方法可以使這項工作。首先,我可以通過將「Property strategy」更改爲「命名分支獲取不同屬性」,然後在「Add property」下選擇「Suppress automatic SCM triggering」來禁用一組分支上的自動構建。其次,我能夠配置Bitbucket來抑制某些用戶的推送通知。通過這樣做,我可以抑制構建服務器用戶的構建,這與我鏈接的文章所用的方法相同。但是,我不知道其他回購是否支持這一點。 – Pace