Jenkins and Git: Local Branch No Longer Referencing Corresponding Remote Branch
I need help understanding the following: I’m running a Jenkins job to build out a project hosted in a remote git repo. I am checking out code to a sub-directory, and checking out specific local branch “test-1.1.” I have a corresponding remote branch as well.
However, when I run the Jenkins build, and run
git branch -av, I get:
- ERROR: Workspace has a .git repository, but it appears to be corrupt
- chromedriver fails on windows jenkins slave running in foreground
- Jenkins remote build issue - email related
- Pushing out smallest repo possible, and issues with git subtree on shallow clone
- Maven release git-push “Host key verification failed.”
- Can I mass edit jenkins jobs by modifying the config.xml files?
* test-1.1 f10e15e Commit Text2 * remotes/origin/test-1.1 818da9e Commit Text1
When I manually perform a git clone, and checkout to branch test-1.1,
git branch -av gives:
* test-1.1 818da9e Commit Text1 * remotes/origin/test-1.1 818da9e Commit Text1
It appears that the Jenkins build is doing the branch checkout differently, but I’m not sure how or what.
How would I get Jenkins to checkout the “test-1.1” (or any other) branch and be at the correct hash, and retain the reference to its corresponding remote branch? I could write a shell script, but would there be any other way of doing this that I might be missing?
Jenkins 1.544 with Git 2.0 plugin, CentOS 6.4.
2 Solutions collect form web for “Jenkins and Git: Local Branch No Longer Referencing Corresponding Remote Branch”
As others already said, Jenkins git plugin has it’s own way of managing the cloning and branches. But it does work. If you want to build branch test-1.1, you type that into the Jenkins job configuration and stop worrying. After the build is finished, you can check from the build page what was the sha of the commit that was built. If it’s not what you expect, only then you should worry.
(I think the reason for the git plugin’s peculiarities are that it is so versatile: It can build multiple branches in multiple repositories. Because of this it does not check out a branch, but it does build from whatever commit is the latest in the branch(es) you want to build.)
If you find it difficult to let go of complete control, you always have the option of configuring the job with no SCM and then you can type the commands to do cloning and branch checkout into the build step box.
Below plugin will help you to parameterized git-hub check out ..see more below