Maven release plugin & jenkins & git error: “HEAD is not a symbolic ref”

When using the Maven Release Plugin with git and jenkins I got the error

during the prepare goal. Fortunately their is an easy solution:

The solution for this problem is described in this post on StackOverflow. The cause of the problem seems to be that the git plugin checks out the branch in detached head state. HEAD is a pointer which tells you which branch you are on. This pointer apparently gets lost while doing the checkout with the Jenkins GIT Plugin.

The problem can be solved in Jenkins┬áby specifying a local branch name for the parameter “Checkout/merge to local branch (optional)” under “Source Code Management”:

A nice explanation of detached head can be found here.

You should also not use shallow clones to avoid this problem.


This problem can be solved by checking out to a named local branch and not using shallow cloning in your jenkins job.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">