Jenkins Pipeline Choose Specific Branch but take from default(master) branch

2.2k Views Asked by At

I have a Jenkins Pipeline that I would like to have a user input on to checkout a specific branch of their choosing. i.e. If I create a branch 'dev' and commit it in git,but Jenkins take a default branch(master)

Can any one please help me take a code from 'dev' branch code

Thanks much in advance.

stage('Git Checkout') { 
  steps {
    checkout(
        [$class: 'GitSCM', 
        branches: [[name: '*/dev']], 
        doGenerateSubmoduleConfigurations: false,
        extensions: [], 
        submoduleCfg: [], 
        userRemoteConfigs: [[credentialsId:'987654322234245676543',
                            url:'http://repo.xyz.com/user/devop.git']]]
    )
   }
}    
1

There are 1 best solutions below

0
On

You can try pipeline step: git

stage('Git Checkout') {
    steps {
        git(branch: 'dev', 
            credentialsId: '987654322234245676543', 
            url: "http://repo.xyz.com/user/devop.git")
    }
}