“Git fatal: ref HEAD is not a symbolic ref” while using maven release plugin

喜夏-厌秋 提交于 2019-12-02 14:25:02

I ran into the same error on Jenkins in combination with maven release plugin, we fixed it by going to Additional behaviours, Check out to specific local branch and enter 'master'

I realise this is not a solution but it might give you some direction in where to look.

For Jenkins and GIT add the additional behaviour check out to specific local branch and use the Workspace Cleanup Plugin to clean your workspace to the beginning of your CI job.

The problem in Atlassian Bamboo was solved by un-checking the default setting Use shallow clones with description Fetches the shallowest commit history possible. Do not use if your build depends on full repository history. This checkbox is located under Plan Configuration -> Repositories tab -> Git -> Advanced options

After this all the releases work fine.

Unchecking the Use shallow clones was not sufficient in my case (I'm using Bamboo 5.7.2). I needed to also enable Force Clean Build in the Source Code Checkout task. Enabling the Use shallow clones would work for the next execution of the job, but all subsequent execution would result in the same error.

I have seen this problem under Bamboo used with Maven Release plug-in. I've fixed it by enabling the option 'Force Clean Build' in the 'Source Checkout' task. Bamboo says this might make the build slower, but it works and I didn't seen any significant time increase.

what worked for me was to call "git checkout -f master" before calling "mvn release"

I am using a Jenkins Team Project with a Multibranch Project Setup.

I previously used checkout scm command.

Now I am using the following code:

checkout([
                 $class: 'GitSCM',
                 branches: scm.branches,
                 extensions: scm.extensions + [[$class: 'CleanCheckout'], [$class: 'LocalBranch', localBranch: 'new']],
                 userRemoteConfigs: scm.userRemoteConfigs
            ])

For us the issue was with maven version specified in the pom file. Corrected the maven version specified in the pom file in accordance with the one in bamboo fixed the issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!