[英]jenkins pipeline project 3 repositories
在我的項目中,我使用的是Multi scm,但很遺憾,我在項目A的分支中有jenkinsFile x,並且我需要兩個輸入輸入1:選擇項目B的分支輸入2:使用GitParameter插件選擇項目CI m的分支
嗨,我確實看過git plugin + git parameter plugin一切都很好,但是當我想選擇每個存儲庫的分支時,它將兩個存儲庫的所有分支重新分組到同一參數中,我猜工作區存在一些問題
所以我做了一些研究,我發現了並奏效。 謝謝你我的朋友的幫助
node() {
stage('select') {
timeout(time: 5)
{
dir("repo x") {
git branch: 'master', credentialsId: 'xxxx', url: 'ssh://xx.git'
String remoteBranchesStr = sh(script: "git branch -r", returnStdout: true).trim()
remoteBranchesStr = remoteBranchesStr.replaceAll(" ", "")
remoteBranchesStr = remoteBranchesStr.replaceAll(",", "")
remoteBranchesStr = remoteBranchesStr.replaceAll("[", "")
remoteBranchesStr = remoteBranchesStr.replaceAll("]", "")
def remoteBranches = [];
remoteBranches= remoteBranchesStr.split('origin/');
gitBranch = input(id: 'x', message: 'Sélectionner la branche x :', parameters: [[$class: 'ChoiceParameterDefinition', choices: "$remoteBranches", description: '', name: 'x : ']])
}
dir("repo y") {
git branch: 'master', credentialsId: 'yyyy', url: 'ssh://y.git'
String remoteBranchesStr = sh(script: "git branch -r", returnStdout: true).trim()
remoteBranchesStr = remoteBranchesStr.replaceAll(" ", "")
remoteBranchesStr = remoteBranchesStr.replaceAll(",", "")
remoteBranchesStr = remoteBranchesStr.replaceAll("[", "")
remoteBranchesStr = remoteBranchesStr.replaceAll("]", "")
def remoteBranches = [];
remoteBranches = remoteBranchesStr.split('origin/');
gitBranch = input(id: 'y', message: 'Sélectionner la branche y:', parameters: [[$class: 'ChoiceParameterDefinition', choices: "$remoteBranches", description: '', name: 'y: ']])
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.