问题描述
给出的是存储库URL的列表,它们只有一部分不同:
http://主机名/ {A} .git
http://主机名/ {B} .git
http://主机名/ {C} .git
我希望我的多分支管道能够从我希望的git存储库中签出。而且,我希望每次通过“使用参数构建”开始工作时都可以选择存储库。
因此,我在Jenkinsfile中做了一些参数化,如下所示:
属性( [ 参数([ 选择(名称:“存储库”,选择“ A \ nB \ nC”) ] ) ] )
问题:如何在我的Jenkins多分支构建作业的配置中添加选择变量(“存储库”)?在Jenkins GUI的“ / configure”下,我可以看到带有“ Git”块的“分支源”,在其中可以将git-repo URL放置为“ Project Repository”。但是如何将选择内容包含在git URL中?
解决方法
我在jenkins管道作业中进行了一些设置。 请检查这种方法是否会对您有所帮助。 ################ 在我的jenkins管道常规工作中,我在那里定义了参数。
def gitrepo1= "repo 1 url"
def gitrepo2= "repo 2 url"
def gitrepo3= "repo 3 url"
then in pipelinejob function,pipelinejob('jobname')
parameters
{
choiceparam('gitrepo',[gitrepo1,gitrepo2,gitrepo3],'')
...............................
...............................
}
definiton
{
......
}
现在,在构建作业时,如果选择带参数的构建,则可以从3个选项中选择gitrepo的值。
谢谢, 超自然