在我的项目中,我有一个GitFlow风格的存储库。
如何让 Jenkins 执行以下操作:(XXXX=Release No)
- 构建 Release-XXXX 分支
- 如果发布分支不存在,则构建主分支。
我知道我可以使用git-chooser-alternative插件按优先顺序排列分支,但我不知道如何选择包含单词 Release- 的分支
在我的项目中,我有一个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)