[英]Jenkins Git Branch Selection with Fallback
在我的項目中,我有一個GitFlow風格的存儲庫。
如何讓Jenkins執行以下操作:(XXXX = Release No)
我知道我可以使用git-chooser-alternative插件按優先順序放置分支,但我不知道如何選擇包含單詞Release的分支 -
您可以使用管道。
def doCheckout(cloneUrl,branches) {
for (String branch : branches) {
try {
deleteDir()
sh 'git config --global credential.helper cache'
checkout([
$class: 'GitSCM',
branches: [[name: branch]],
extensions: [
[$class: 'CloneOption',
noTags: false,
reference: '',
shallow: true,
honorRefspec: true],
[$class: 'WipeWorkspace'],
[$class: 'CleanBeforeCheckout']
],
submoduleCfg: [],
userRemoteConfigs: [
[ credentialsId: 'someCredentialId', url: cloneUrl]
]
])
sh "git checkout ${branch}"
return
} catch (Throwable throwable) {
//Try next...
}
}
throw new RuntimeException("Could not find any of the ${branches} from ${cloneUrl}")
}
def branches = ['release','develop','master']
doCheckout(cloneUrl, branches)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.