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

Jenkins Git插件分离头

孙泳
2023-03-14

我是Git和Jenkins的新手,我的问题是我无法让Jenkins Maven发布插件正常工作。

当我用Jenkins构建一个普通的Maven构建时,它工作得很好,但是当我尝试用Maven发布插件执行发布时,我得到了以下堆栈跟踪:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project parent: 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.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
    at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:158)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:98)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:64)
    at hudson.remoting.UserRequest.perform(UserRequest.java:118)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:326)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
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:295)
    at org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:247)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 27 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:291)
    ... 30 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)
    ... 38 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)
    ... 42 more
channel stopped
Finished: FAILURE

失败的命令和错误消息是:

[INFO] Executing: /bin/sh -c cd
/var/lib/jenkins/workspace/test_maven/parent && git symbolic-ref HEAD
[INFO]  Working directory:
/var/lib/jenkins/workspace/test_maven/parent  mojoFailed
org.apache.maven.plugins:maven-release-plugin:2.3.2(default-cli)
projectFailed ch.apkern.achilles:parent:1.0-SNAPSHOT  sessionEnded

我发现Jenkins Git插件创建了一个分离的HEAD ref“(无分支)”,我认为这是问题的根源。但我完全不知道为什么会创建这个ref,也不知道如何解决这个问题。

如果有任何帮助,我将不胜感激。

共有3个答案

易成双
2023-03-14

更新(2015年11月):请注意,此解决方案是针对特定版本的Git插件(1.1.26)提供的。在以后的版本中,插件被更新以使配置更容易。

对于Jenkins Git插件版本1.1.26,请尝试以下操作:

转到作业配置。向下滚动到Git部分,点击“高级…”“存储库”下的按钮。然后设定:

Name: origin
Refspec: +refs/heads/branch-0.1:refs/remotes/origin/localbranchname

然后点击另一个“高级...”按钮并设置:

Checkout/merge to local branch (optional): localbranchname

可以随意命名本地分支,但Refspec中的目的地必须与该可选字段中的本地分支名称匹配(在本例中为“localbranchname”)。这会像这样将头部连接到localbranchname:

HEAD -> refs/heads/localbranchname -> 7a698457751bdc043cfda631b81e3812c5361790

马文的释放现在应该在詹金斯通过了。

顺便说一句,Jenkins 1.492和Jenkins Git插件版本1.1.26对我来说是有效的。

申屠鹏
2023-03-14

如果不创建手动步骤,其他答案的詹金斯配置都不适合我。真正有效的是简单明了的:

Repository URL: <repo>
Branches to build: master
Checkout/merge to local branch (optional): master
洪楷
2023-03-14

签出/合并到本地分支(可选)字段在当前(2.2.1)版本的Git插件中消失。

它已经移动到附加行为→签出到特定的本地分支:

将该值设置为master会使我得到一个签出的分支,而不是一个分离的头部。

 类似资料:
  • 我正在使用Jenkins Git插件(v2.0)的分支说明符选项在特定的分支上运行构建,例如,<代码>1.4 。 在这种情况下包含值。 如何接收用于克隆的本地Git分支的名称(即只有没有前缀? 我尝试了使用分支名称查看特定本地分支的其他行为,但没有任何改变。 我在GitHub上看到过相关的PR,但被拒绝了(因为它只修复了一个只有远程的情况)。

  • 詹金斯v2。19 Git插件v2。5.3 在分支构建下,我指定了2个分支: 和 这将导致在{git commit hash}处分离

  • 我试图使用Jenkins/Kubernetes插件来协调docker奴隶与Jenkins。 我正在使用这个插件:https://github.com/jenkinsci/kubernetes-plugin 我的问题是所有的从机都离线了,所以作业无法执行: 我已经用minikube在我的本地盒子上和我们的ops组托管的K8集群上尝试了这一点。我试过Jenkins1.9和Jenkins2。我总是得到同

  • 我想用gradle编译一个vertx项目。我想把它编译成一个独立的jar,我读到这可以通过gradle的shadow插件实现。 现在,我需要能够在离线环境中做到这一点。我下载了插件的源代码并将其编译成一个jar。现在,我想在我的项目中应用该jar中的插件build.gradle.我不知道如何做到这一点。 我知道这些答案,但似乎都不起作用。 目前,我有: 当我运行“gradle build”时,我得

  • 代码示例 const interpolant = new THREE.DiscreteInterpolant( new Float32Array( 2 ), new Float32Array( 2 ), 1, new Float32Array( 1 ) ); interpolant.evaluate( 0.5 ); Constructor DiscreteInterpolant( paramete

  • 我正在我的应用程序中使用cordova插件ionic键盘插件。在键盘出现之前,我的Ui如下所示: 但是,当键盘出现时,它会破坏应用程序的布局,如下所示: 然后,我试图停止布局的调整大小在config.xml使用下面的代码: