In my project I was using Multi scm but it's depricated I have the jenkinsFile in project A branche x and I need two inputs input 1 : to select a branche of project B input 2 : to select a branche of project C I m using GitParameter plugin
2 Answers
From your question it appears that these projects are clearly related. They should therefore be part of the same solution. (I am assuming you are using .NET, but the idea still holds if that is not the case.)
Once they are held together in one solution I would suggest that the current best practice (at time of writing weekly release is 2.85) is to use a multi branch pipeline job which will detect branches in a given repository automatically. In this way Jenkins more closely integrates with the way Git and GitHub function.
Given you have advised that your projects are unrelated, I would suggest that you put all your source code in Git and use the Git plugin which allows you to dynamically specify the branch name with a parameter.

- 3,593
- 3
- 35
- 62
-
my projects are not related what I need is two parameters to select the branch to build on each project – mouad Oct 18 '17 at 14:36
hi I did look at the git plugin + git parameter plugin everything is good ,but when I wanted to select the branch of each repo it regrouped all the branchs of both repositories in the same parameter , some problem with the workspace i guess
So I did some research and I found this and it works . thank you my friend for your help
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: ']])
}
}
}
}

- 31
- 4