How can I use the Jenkins Git plugin to check out a specific branch? I have installed Jenkins and I use the GIT plugin to clone a repository. Any help would be greatly appreciated.
If you want to check out a remote branch someone published, you first have to use git fetch . This command downloads the references from your remote repository to your local machine, including the reference to the remote branch. Now all you need to do is use git checkout <remote branch name> .
If you have a single remote repository, then you can omit all arguments. just need to run git fetch , which will retrieve all branches and updates, and after that, run git checkout <branch> which will create a local copy of the branch because all branches are already loaded in your system.
There is an option to pass branch name in Jenkins Git Plugin/ Git Parameter Plugin.
This accepts build parameters. So you could add parameter to the job, say with BRANCH_NAME and pass it to git plugin. Options are Just above the "Repository Browser" setting
Here is with build parameter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With