3ipx_a
Last Updated: October 30, 2017
·
573
· superboum
Avatar1

GitVersion "It looks like the branch being examined is a detached Head" on Jenkins

This fix was tested on a multibranch pipeline project.
If you have something like the following error:

It looks like the branch being examined is a detached Head pointing to commit '2c8abb2'.
Without a proper branch name GitVersion cannot determine the build version.

That's because jenkins fetch a specific git commit without associating it to a branch.
You can see it by running git status

HEAD detached at 2c8abb2

The solution is easy, you have to say to Jenkins to clone it in its branch. More precisely, to clone it in a local branch.

On your project configuration, where you have setup the path to your git repository, add an Additional Behaviour, the one named Checkout to a specific local branch.
But you don't want to use the same local branch for all your branch. That's not a problem ! Just leave the text box empty or write in it **. For more information, you can read the associated help message:

If given, checkout the revision to build as HEAD on this branch.
If selected, and its value is an empty string or "**", then the branch name is computed from the remote branch without the origin. In that case, a remote branch origin/master will be checked out to a local branch named master, and a remote branch origin/develop/new-feature will be checked out to a local branch named develop/newfeature.
Please note that this has not been tested with submodules.

Say Thanks
Respond
Filed Under