当前位置: 首页 > 知识库问答 >
问题:

使用maven release插件时出现“Git fatal: ref HEAD不是符号ref”

席言
2023-03-14

在运行Maven发布插件准备步骤时,我得到以下错误输出,即mvn发布:从艾特莱森竹子计划中准备--batch-mode-DeleaseVersion=1.1.2.0-DDevelopment mentVersion=1.2.0-SNAPSHOT-Dtag=v1.1.2-X。但是在命令行中执行相同的操作效果很好。完整的错误堆栈如下。

有什么办法可以解决这个问题吗?

[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

更新:

在本地工作区克隆上执行<code>git ls remote.</code>会产生:

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^{}

在 Bamboo 克隆上执行 git ls-remote . 会生成:

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^{}

这是非常奇怪的,为什么本地开发克隆输出与Bamboo输出如此不同?

共有3个答案

柴声
2023-03-14

艾特莱森竹子中的问题是通过取消选中默认设置使用带有描述的浅克隆来解决的。获取尽可能浅的提交历史记录。如果您的构建依赖于完整的存储库历史记录,请不要使用。此复选框位于计划配置下-

在此之后,所有的版本工作正常。

马淳
2023-03-14

对于Jenkins和GIT,将附加行为签出添加到特定的本地分支,并使用Workspace Cleanup Plugin将工作区清理到CI作业的开始。

傅毅然
2023-03-14

我在Jenkins与maven发布插件的组合中遇到了同样的错误,我们通过转到其他行为,检查特定的本地分支并输入“master”来修复它

我意识到这不是一个解决方案,但它可能会给你一些方向。

 类似资料:
  • 我试图将Stripe Java库与JSP Java servlets一起使用。 我已经将以下库导入servlet AcceptPaymentRequest.java中: 我的pom.xml如下: 找不到符号:class APIException位置:package com.stripe.exception 任何帮助都很感激。

  • 我有一个类,如下所示: 我得到以下错误: [错误]无法执行目标组织。阿帕奇。专家插件:maven javadoc插件:2.10。4:project foo上的javadoc(默认cli):JavaDocs报告生成中发生错误: [错误]退出代码:1-/home/workspace/foo/src/main/java/com/foo/foo。java:34:错误:找不到symbol [error]公共

  • 我的第一个猜测是,这是一个数据库配置问题,但我已经确认(尽我所知),Postgres确实通过执行以下操作来接受UTF-8: 我还通过手动向数据库中插入一个条目进一步证实了这一点: 从上面可以理解,数据库已经接受了我的值,并且已经成功地将Unicode字符添加到数据库中。 我排除了应用程序的代码,因为它是一个非常大的项目的一部分,并且相关的部分在这里和那里是支离破碎的。但是,我认为它们与问题无关,因

  • 我正在创建一个程序,用户(教师)在其中输入一组百分比分数,并对这些分数进行分析,输出框打印出平均值、最小值/最大值、范围和“R级”、“1级”、“2级”等分数。 我面临的问题是将分数分为不同级别的方法。当我尝试将数组返回到main方法,并尝试将其打印到输出时,我得到了一个数组错误,即“找不到符号” 因此,当我使用主方法打印所有信息时,我应该将levelCount数组放入另一个数组中,我做到了。以下是

  • 我在使用文件选择器包后出错。我对此搜索了很多,但仍然无法解决问题。我也试过清理,但也不管用。 错误如下:{ 失败:构建失败,但有一个异常。 错误:任务执行失败:应用程序:processDebugResources 执行com.android.build.gradle.internal.tasks时出错。Workers$ActionFacade Android资源链接失败F:\flatter\bit

  • 我正在使用下面的代码创建java。util。功能 但是,我得到一个“未找到符号”异常。请帮忙 下面是代码片段: 编译器抛出错误:java:找不到symbol:方法doubleIt_1(java.lang.Integer)位置:类声明性。L12Legacytomfunction接口4 请帮忙...