Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use the git plugin to checkout a specific branch

Tags:

jenkins

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.

like image 232
James Umeris Avatar asked Jan 09 '16 04:01

James Umeris


People also ask

How do I checkout someone's branch?

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> .

How do I fetch a single branch?

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.


1 Answers

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

click the image to see the full picture.

Here is with build parameter with parameter called BRANCH_NAME

like image 89
Jayan Avatar answered Sep 20 '22 18:09

Jayan