17 December, 2014

Detecting the current branch failed: fatal: ref HEAD is not a symbolic ref



This issue occurs when I tried with Jenkins build using Maven Release Plugin. I was trying to build my production release artifacts. I was building my "master" branch and its for final release. I have used Git as repository. I faced this issue when clicked on "maven release build" link on left side corner of my Maven project (Jenkins job) .


As we know build issue is common for developers those are actively participating with Build and Release. This issue over Jenkins is common , but I never found any direct or easy solution for this. I spend couple of hour to resolve and goooogle almost all relavant sites and article.But, not able to work out. Finally did it by some HIT and TRY ,then it works for me.   


Issue log details :-

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.884s
[INFO] Finished at: Wed Dec 17 18:05:43 EST 2014
[INFO] Final Memory: 15M/301M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project hello_world_app: An error is occurred in the checkin process: Exception while executing SCM command. Detecting the current branch failed: fatal: ref HEAD is not a symbolic ref -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[JENKINS] Archiving /opt/jenkins_dev/workspace/SDP_BIZ_HELLO_WORLD_APP/pom.xml to in.com.company.xcop.sdp.bizservice.test.dao/hello_world_app/0.0.8-SNAPSHOT/ hello_world_app -0.0.8-SNAPSHOT.pom
channel stopped
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds



Solution :-

 In Jenkins job , open the configuration and go to Git configuration => Advance Options => << add your local branch name >>. In my case I have added "master" .

If you are using some other version of jerkins then , you may find the similar settings with other way. In the same way Git configuration => Advance Options => Additional Behaviors => Check out to specific local branch => << Add your local branch name >>.   

Attached the screenshot below with highlight. 







Hope it will help you. Happy Building.

2 comments:

  1. It's very useful, thank you so much :))

    ReplyDelete
  2. Gracias por la explicación, me fue de mucha utilidad.

    ReplyDelete