带回退的Jenkins Git分支选择
在我的项目中,我有一个样式库 我怎样才能让詹金斯做到以下几点:(XXXX=发布号)带回退的Jenkins Git分支选择,git,github,jenkins,bitbucket,jenkins-plugins,Git,Github,Jenkins,Bitbucket,Jenkins Plugins,在我的项目中,我有一个样式库 我怎样才能让詹金斯做到以下几点:(XXXX=发布号) 构建发布XXXX分支 如果发布分支不存在,则生成主分支 我知道我可以使用插件将分支按优先级排序,但我不知道如何选择包含单词Release的分支-您可以使用管道来实现这一点 def doCheckout(cloneUrl,branches) { for (String branch : branches) { try { deleteDir() sh 'git config --global cr
我知道我可以使用插件将分支按优先级排序,但我不知道如何选择包含单词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)
嗨,我也有同样的问题,但我需要一个声明性管道的解决方案。有人能帮我吗?