本文介绍了“Git fatal:ref HEAD is not a symbolic ref”同时使用Maven发布插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
运行Maven发布插件准备步骤时,我得到以下错误输出,即 mvn release:prepare --batch-mode -DreleaseVersion = 1.1.2 -DdevelopmentVersion = 1.2.0-SNAPSHOT -Dtag =来自Atlassian Bamboo计划的v1.1.2-X
。但是,在命令行中执行相同的工作正常。
任何想法如何解决? c $ c> [错误]无法执行目标org.apache.maven.plugins:maven-release-plugin:2.4.2:在项目上准备(default-cli)hpcmom:检入过程中发生错误:异常执行SCM命令。检测当前分支失败:fatal:ref HEAD不是符号ref - > [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException:无法执行目标org.apache.maven.plugins:maven-release-plugin:2.4.2:在项目hpcmom上准备(default-cli)签入过程中发生错误:执行SCM命令时发生异常。
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
在org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
在org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
在org.apache.maven .cli.MavenCli.doMain(MavenCli.java:
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect。 NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
在java.lang.reflect.Method.invoke(Method.java:606)
在org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
导致:org.apache.maven.plugin.MojoExecutionException:签入过程中发生错误:执行SCM命令时发生异常。
at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:281)
at org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:232)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
导致:org.apache.maven.shared.release.ReleaseExecutionException:签入过程中发生错误:执行SCM命令时发生异常。
在org.apache.maven.shared.release.phase.AbstractScmCommitPhase.checkin(AbstractScmCommitPhase.java:160)
在org.apache.maven.shared.release.phase.AbstractScmCommitPhase.performCheckins(AbstractScmCommitPhase。 java:145)
at org.apache.maven.shared.release.phase.ScmCommitPreparationPhase.runLogic(ScmCommitPreparationPhase.java:76)
at org.apache.maven.shared.release.phase.AbstractScmCommitPhase。执行(AbstractScmCommitPhase.java:78)
at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:234)
at org.apache.maven.shared.release.DefaultReleaseManager。准备(DefaultReleaseManager.java:169)
在org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:146)
在org.apache.maven.shared.release.DefaultReleaseManager。准备(DefaultReleaseManager.java:107)
在org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:277)
... 22 more
引起:org.apache.maven.scm.ScmException:执行SCM命令时发生异常。
at org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:63)
at org.apache.maven.scm.provider.git.AbstractGitScmProvider.executeCommand(AbstractGitScmProvider.java:
at org.apache.maven.scm.provider.AbstractScmProvider.checkIn(AbstractScmProvider。
at org.apache.maven.scm.provider.git.AbstractGitScmProvider.checkin(AbstractGitScmProvider.java:217)
at org.apache.maven.scm.provider.AbstractScmProvider.checkIn(AbstractScmProvider。 java:410)
at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.checkin(AbstractScmCommitPhase.java:156)
... 30 more
由org.apache引起.maven.scm.ScmException:检测当前分支失败:致命:ref HEAD不是符号ref
,位于org.apache.maven.scm.provider.git.gitexe.command.branch.GitBranchCommand .getCurrentBranch(GitBranchCommand.java:147)
在org.apache.maven.scm.provider.git.gitexe.command.checkin.GitCheckInCommand.createPushCommandLine(GitCheckInCommand.java:192)
在org.apache .maven.scm.provider.git.gite xe.command.checkin.GitCheckInCommand.executeCheckInCommand(GitCheckInCommand.java:132)
在org.apache.maven.scm.command.checkin.AbstractCheckInCommand.executeCommand(AbstractCheckInCommand.java:54)
。在组织。 apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:59)
... 34 more
[错误]
[错误]
[错误] For more有关错误和可能解决方案的信息,请阅读以下文章:
[错误] [帮助1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
简单02-Dec -2013 17:18:09自[/opt/dev/apache-maven/3.0.5//bin/mvn -Djava.io.tmpdir = / opt / atlassian / bamboo / 5.2.1 / temp的返回码以来的任务失败/ HPCMOM-RELEASE-JOB1发行版:准备--batch-mode -DignoreSnapshots = false -DreleaseVersion = 1.1.2 -DdevelopmentVersion = 1.2.0-SNAPSHOT -Dtag = v1.1.2 -X]为1,而预期为0
更新:
git ls-remote。
在lo上cal工作区克隆产生:
azg @ olympus:〜/ code / hpcmom $ git ls-remote。
7894eea08a0afecb99515d1339623be63a7539d4 HEAD
7894eea08a0afecb99515d1339623be63a7539d4裁判/头/主
7894eea08a0afecb99515d1339623be63a7539d4参/遥控器/产地/ HEAD
7894eea08a0afecb99515d1339623be63a7539d4参/遥控器/产地/主
6a7095b86cccdfd4b28e4dea633d0930809ae9ac裁判/标签/ V1 0.0
1a53462b1ecf0abfea8245016304cda9c78b420d裁判/标签/ 1.0 ^ {}
5113a7cbcf35c47b680a9c36e15e5fa01ef1d2e6裁判/标签/ V1.1
79a3073ecabe65d3c8051520f8007d9e49a65a06裁判/标签/ V1.1 ^ {}
a00249209597ea1214d80ee38f228c40db7022c2裁判/tags/v1.1.0
e892bce8d25d87368ab557fee0d30810bef7e31e refs / tags / v1.1.0 ^ {}
b491a312c39088533cb069e4ab1ae8a00d1f6bfe refs / tags / v1.1.2
a3f7618dada7ed60d8190426152ffd90e0e40a86 refs / tags / v1.1.2 ^ {}
在Bamboo克隆上执行 git ls-remote。
生成:
azg @ olympus:/ var / atlassian / application-data / bamboo / xml-data / build-dir / H PCMOM-RELEASE-JOB1 $ git ls-remote。
2422ce066ac35dae3c54f1435ef8dae5008a9a14 HEAD
57c08d581c0fd9e788049733fbdc9c22b9a6ae00裁判/头/主
57c08d581c0fd9e788049733fbdc9c22b9a6ae00参/遥控器/产地/ HEAD
57c08d581c0fd9e788049733fbdc9c22b9a6ae00参/遥控器/产地/主
7539f9700d78a1b766fca7ed9f409914f1ea9d08裁判/标签/ VNULL
6bfa8c3fdb1f8f56a385035f01b1b77b6e88da8b refs / tags / vnull ^ {}
这很奇怪,为什么本地开发的克隆输出与Bamboo的不同之处在哪里?解决方案
使用浅层克隆
和描述获取尽可能最浅的提交历史记录。如果您的构建取决于完整的资料库历史记录,请勿使用
。此复选框位于计划配置 - >存储库选项卡 - > Git - >高级选项
此后所有发布工作正常。
I get the following error output while running the Maven release plugin prepare step i.e. mvn release:prepare --batch-mode -DreleaseVersion=1.1.2 -DdevelopmentVersion=1.2.0-SNAPSHOT -Dtag=v1.1.2 -X
from an Atlassian Bamboo plan. However doing the same in the command line works fine. The full error stack is below.
Any ideas how can this be solved?
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.2:prepare (default-cli) on project hpcmom: 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]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.2:prepare (default-cli) on project hpcmom: An error is occurred in the checkin process: Exception while executing SCM command.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: An error is occurred in the checkin process: Exception while executing SCM command.
at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:281)
at org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:232)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: org.apache.maven.shared.release.ReleaseExecutionException: An error is occurred in the checkin process: Exception while executing SCM command.
at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.checkin(AbstractScmCommitPhase.java:160)
at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.performCheckins(AbstractScmCommitPhase.java:145)
at org.apache.maven.shared.release.phase.ScmCommitPreparationPhase.runLogic(ScmCommitPreparationPhase.java:76)
at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.execute(AbstractScmCommitPhase.java:78)
at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:234)
at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:169)
at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:146)
at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:107)
at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:277)
... 22 more
Caused by: org.apache.maven.scm.ScmException: Exception while executing SCM command.
at org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:63)
at org.apache.maven.scm.provider.git.AbstractGitScmProvider.executeCommand(AbstractGitScmProvider.java:291)
at org.apache.maven.scm.provider.git.AbstractGitScmProvider.checkin(AbstractGitScmProvider.java:217)
at org.apache.maven.scm.provider.AbstractScmProvider.checkIn(AbstractScmProvider.java:410)
at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.checkin(AbstractScmCommitPhase.java:156)
... 30 more
Caused by: org.apache.maven.scm.ScmException: Detecting the current branch failed: fatal: ref HEAD is not a symbolic ref
at org.apache.maven.scm.provider.git.gitexe.command.branch.GitBranchCommand.getCurrentBranch(GitBranchCommand.java:147)
at org.apache.maven.scm.provider.git.gitexe.command.checkin.GitCheckInCommand.createPushCommandLine(GitCheckInCommand.java:192)
at org.apache.maven.scm.provider.git.gitexe.command.checkin.GitCheckInCommand.executeCheckInCommand(GitCheckInCommand.java:132)
at org.apache.maven.scm.command.checkin.AbstractCheckInCommand.executeCommand(AbstractCheckInCommand.java:54)
at org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:59)
... 34 more
[ERROR]
[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
simple 02-Dec-2013 17:18:09 Failing task since return code of [/opt/dev/apache-maven/3.0.5//bin/mvn -Djava.io.tmpdir=/opt/atlassian/bamboo/5.2.1/temp/HPCMOM-RELEASE-JOB1 release:prepare --batch-mode -DignoreSnapshots=false -DreleaseVersion=1.1.2 -DdevelopmentVersion=1.2.0-SNAPSHOT -Dtag=v1.1.2 -X] was 1 while expected 0
UPDATE:
Doing git ls-remote .
on a local workspace clone produces:
azg@olympus:~/code/hpcmom$ git ls-remote .
7894eea08a0afecb99515d1339623be63a7539d4 HEAD
7894eea08a0afecb99515d1339623be63a7539d4 refs/heads/master
7894eea08a0afecb99515d1339623be63a7539d4 refs/remotes/origin/HEAD
7894eea08a0afecb99515d1339623be63a7539d4 refs/remotes/origin/master
6a7095b86cccdfd4b28e4dea633d0930809ae9ac refs/tags/v1.0
1a53462b1ecf0abfea8245016304cda9c78b420d refs/tags/v1.0^{}
5113a7cbcf35c47b680a9c36e15e5fa01ef1d2e6 refs/tags/v1.1
79a3073ecabe65d3c8051520f8007d9e49a65a06 refs/tags/v1.1^{}
a00249209597ea1214d80ee38f228c40db7022c2 refs/tags/v1.1.0
e892bce8d25d87368ab557fee0d30810bef7e31e refs/tags/v1.1.0^{}
b491a312c39088533cb069e4ab1ae8a00d1f6bfe refs/tags/v1.1.2
a3f7618dada7ed60d8190426152ffd90e0e40a86 refs/tags/v1.1.2^{}
Doing git ls-remote .
on the Bamboo clone produces:
azg@olympus:/var/atlassian/application-data/bamboo/xml-data/build-dir/HPCMOM-RELEASE-JOB1$ git ls-remote .
2422ce066ac35dae3c54f1435ef8dae5008a9a14 HEAD
57c08d581c0fd9e788049733fbdc9c22b9a6ae00 refs/heads/master
57c08d581c0fd9e788049733fbdc9c22b9a6ae00 refs/remotes/origin/HEAD
57c08d581c0fd9e788049733fbdc9c22b9a6ae00 refs/remotes/origin/master
7539f9700d78a1b766fca7ed9f409914f1ea9d08 refs/tags/vnull
6bfa8c3fdb1f8f56a385035f01b1b77b6e88da8b refs/tags/vnull^{}
and this is very weird why is the local development clone output so different from the Bamboo one?
解决方案
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.
这篇关于“Git fatal:ref HEAD is not a symbolic ref”同时使用Maven发布插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!