List Git Branches Parameter | Jenkins pluginAdds ability to choose from git repository revisions or tagshttps://plugins.jenkins.io/list-git-branches-parameter/
1、安裝組件??List Git Branches
2、驗(yàn)證功能
1)新建任務(wù)?
2)新增構(gòu)建參數(shù)?
3)選擇git倉(cāng)庫(kù)
我這里選擇gitee,其他類(lèi)似。倉(cāng)庫(kù)如果不是公開(kāi)的,需要配置key?
4)jenkins配置git倉(cāng)庫(kù)
5)開(kāi)始構(gòu)建
點(diǎn)擊【build with praameters】,可以選擇git分支版本了
6)優(yōu)化git分支名稱(chēng)
選擇【配置】—>【高級(jí)】,在【branch filter】添加“refs/heads/(.*)”,點(diǎn)擊保存
選擇【build with parameters】分支名稱(chēng)更簡(jiǎn)潔了
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-716923.html
?最后拿到分支了就是去拉取指定分支的代碼了,注意這里是"${env.BRANCH}"而不是單引號(hào)!!文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-716923.html
pipeline {
agent any
stages {
stage('Hello') {
steps {
script{
print(env.BRANCH)
checkout([$class: 'GitSCM', branches: [[name: "${env.BRANCH}"]], extensions: [], userRemoteConfigs: [[credentialsId: '33375fd1-0418-4b7a-a65e-4ffcebd8e7da', url: 'http://192.168.11.129/root/devops-maven-service.git']]])
}
}
}
}
}
到了這里,關(guān)于Jenkins List Git Branches插件 構(gòu)建選擇指定git分支的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!