我在管道作业上使用git参数插件 我需要从两个不同的存储库获取所有分支 这是我的剧本
#!groovy
node{
checkout scm
properties ([
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '3', daysToKeepStr: '', numToKeepStr: '5')),
parameters([
[$class: 'GitParameterDefinition',
name: 'gitBranchCustomer',
description: ' branches projet 1',
type:'Branch',
branch: '',
branchFilter: '.*',
tagFilter:'*',
sortMode:'NONE',
defaultValue: '',
selectedValue:'NONE',
quickFilterEnabled: false],
[$class: 'GitParameterDefinition',
name: 'gitBranchCore',
description: 'branches projet 2',
type:'Branch',
branch: '',
branchFilter: '.*',
tagFilter:'*',
sortMode:'NONE',
defaultValue: '',
selectedValue:'NONE',
quickFilterEnabled: false],
])
])
stage('select'){
timeout(time:5){
Environement = input( parameters: [ [$class: 'ChoiceParameterDefinition', choices: 'production\npreprod\nrecette', description: '', name: 'Environement : '] ])
println "Property: $Environement"
if(Environement.equals("production")){
Mode_de_livraison = input( parameters: [ [$class: 'ChoiceParameterDefinition', choices: 'Copie preprod\nRelivraison branche production', description: '', name: ' Mode de livraison : '] ])
}else{
Mode_de_livraison = input( parameters: [ [$class: 'ChoiceParameterDefinition', choices: 'Full\nRelivraison branche pre-production', description: '', name: ' Mode de livraison : '] ])
}
println "Property: $Mode_de_livraison"
}
}
//stage('checkout') {git branch: "master", credentialsId: '2d43b72d-fadc-446c-aaff-050a904b8ba9', url: 'https://github.com/mouadiativ/formation-test-1.git'}
}
问题是它在一个参数中重新组合所有分支 enter image description here
答案 0 :(得分:0)
您需要至少一次签出要使用的所有存储库,以便Jenkins保存有关SCM的信息。
您可以只使用git
DSL签出其他远程服务器(“ SCM管道”之外),将其插入管道中并运行一次管道:
#!groovy
node{
git branch: "master", credentialsId: CRED_ID, url: URL
checkout scm
return // this will end build
properties ([
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '3', daysToKeepStr: '', numToKeepStr: '5')),
parameters([...
然后在GitParameterDefinition
中有一个useRepository
参数,您可以在一个git参数中将其设置为customer
并在另一个core
中进行设置(如果这些是您的名称回购):
parameters([
[$class: 'GitParameterDefinition',
name: 'gitBranchCustomer',
description: ' branches projet 1',
type:'Branch',
branch: '',
branchFilter: '.*',
tagFilter:'*',
sortMode:'NONE',
defaultValue: '',
selectedValue:'NONE',
quickFilterEnabled: false,
useRepository: 'customer'], // < ------ here
[$class: 'GitParameterDefinition',
name: 'gitBranchCore',
description: 'branches projet 2',
type:'Branch',
branch: '',
branchFilter: '.*',
tagFilter:'*',
sortMode:'NONE',
defaultValue: '',
selectedValue:'NONE',
quickFilterEnabled: false,
useRepository: 'core'] // < ------ and here
])