【问题标题】:Why does Jenkins fail to git init and return status code 1?为什么 Jenkins 无法 git init 并返回状态码 1?
【发布时间】:2016-05-10 20:12:54
【问题描述】:

场景

  • 我们有两个构建从站(xcode7xcode2)运行完全相同的 Mac OS X El Capitan 实例,并且都使用相同的构建工具 (Xcode 7.3)。
  • 在 Jenkins SSH 从属插件凭据中设置了一个名为“superbuilder”的用户帐户,它在通过私钥和密码启动 SSH 时提供凭据。 superbuilder 是两个构建从站上都存在的用户,并且在两台机器上都有匹配的私钥和公钥。
  • 其中一个从属服务器 (xcode2) 可以克隆我们的存储库,而另一个 (xcode7) 则不能,因为 git init 失败 with status code 1:(请参阅下面的堆栈跟踪)。

事物的不同版本

  • Jenkins 版本:1.580.1
  • Git 插件版本:1.13.3
  • SSH 从站插件版本:1.9
  • 两台机器上的 Git 版本:2.6.4 (Apple Git-63)

我在 xcode7 上尝试过什么

  • 广泛搜索 Jenkins 错误和“状态代码 1:”。
  • 确保superbuilder 用户拥有与xcode2 上完全相同的公钥、私钥和已知主机。
  • SSH 直接进入xcode7 并在本地调用完全相同的 git clone 命令。这成功了,我可以手动克隆 repo。
  • 确保git 二进制文件在其$PATH 上对superbuilder 可见。
  • 确保 buildmaster 对 jenkins 工作区目录具有读/写/执行权限。
  • 确保DEVELOPER_DIR 被注入一个环境变量并指向/Applications/Xcode

问题

  • xcrun error 是否相关?我的意思是 是我的问题的根源还是其他原因?
  • status code 1 指的是什么?
  • 为什么git init 在通过 Jenkins SSH 从属插件运行时会失败?
  • 如果你能帮忙,我可以给你买杯啤酒吗?
  • 这是真实的生活吗?

来自 Jenkins 构建作业的堆栈跟踪

[EnvInject] - Mask passwords passed as build parameters.
Started by user anonymous
[EnvInject] - Loading node environment variables.
Building remotely on xcode7-xcode (xcode7) in workspace /var/jenkins/workspace/mobile.iphone-app-xcode7.ci
Cloning the remote Git repository
Cloning repository git@git.somecorp.com:mobile/iphone-app.git
 > git init /var/jenkins/workspace/mobile.iphone-app-xcode7.ci # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init /var/jenkins/workspace/mobile.iphone-app-xcode7.ci
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:656)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:463)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:152)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:145)
    at hudson.remoting.UserRequest.perform(UserRequest.java:121)
    at hudson.remoting.UserRequest.perform(UserRequest.java:49)
    at hudson.remoting.Request$2.run(Request.java:324)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
    at ......remote call to xcode7-xcode(Native Method)
    at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1356)
    at hudson.remoting.UserResponse.retrieve(UserRequest.java:221)
    at hudson.remoting.Channel.call(Channel.java:752)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:145)
    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.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:131)
    at com.sun.proxy.$Proxy81.execute(Unknown Source)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1057)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1097)
    at hudson.scm.SCM.checkout(SCM.java:488)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1253)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:622)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:528)
    at hudson.model.Run.execute(Run.java:1745)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:89)
    at hudson.model.Executor.run(Executor.java:240)
Caused by: hudson.plugins.git.GitException: Command "git init /var/jenkins/workspace/mobile.iphone-app-xcode7.ci" returned         status code 1:
stdout: 
stderr: xcrun: error: missing DEVELOPER_DIR path: /Applications/Xcode
... 

【问题讨论】:

  • 这看起来很相关:error: missing DEVELOPER_DIR path: /Applications/Xcode
  • /Applications/Xcode 是否存在于 xcode7 上?
  • 它没有。但我也从xcode7-code Jenkins 配置屏幕上删除了那个 ENV 变量。
  • 我也不确定这是否是我的问题。
  • @mkasberg 我认为您对那个奇怪的 ENV 变量可能是正确的。以前,每当我们与该从属设备建立连接时,我都会注入它,但我停止注入它,但我从未重新启动机器。我循环了从机,现在之前注入的 ENV 变量已经消失了。如果您放弃与此相关的答案,我会将其标记为已接受。

标签: git unix plugins jenkins


【解决方案1】:

它抱怨的错误是error: missing DEVELOPER_DIR path: /Applications/Xcode。是否在两台机器上都设置了该变量?两台机器一样吗?该目录是否存在并且在两台机器上都包含相同的内容?

【讨论】:

  • 你是对的。这就是这一切的可疑之处。我删除了这个变量的注入,重启了从机,status code 1 错误信息得到了解决。感谢@mkasberg 让我看到了我忽略的显而易见的事情。
【解决方案2】:

我希望将 Jenkins 更新到最新版本有帮助

Jenkins 1.509.4发现并修复了这个错误

See

我认为您可以尝试创建远程工作目录手册并从控制台运行此命令。这将是某种解决方法

【讨论】:

  • 这是很好的信息,可能也是我的问题的一部分。
猜你喜欢
  • 2017-12-14
  • 2022-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-01
  • 2011-07-27
  • 1970-01-01
相关资源
最近更新 更多