【发布时间】:2014-07-11 03:01:01
【问题描述】:
我们正在尝试通过 Jenkins 作业构建 iOS 应用程序,但我们无法从 Gitlab 实例克隆存储库。截至目前,当 git 获取引用时,Jenkins 会挂起(直到 10 分钟超时)。
以下是 Jenkins 输出:
Started by user <USER>
[EnvInject] - Loading node environment variables.
Building remotely on Mac_Slave in workspace /Users/<MAC USER>/Documents/Jenkins/workspace/<REPO>
> git rev-parse --is-inside-work-tree
Fetching changes from the remote Git repository
> git config remote.origin.url git@<GITLAB>:<USERNAME>/<REPO>.git
Fetching upstream changes from git@<GITLAB>:<USERNAME>/<REPO>.git
> git --version
using GIT_SSH to set credentials <MAC SLAVE>
> git fetch --tags --progress git@<GITLAB>:<USERNAME>/<REPO>.git +refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
FATAL: Failed to fetch from git@<GITLAB>:<USERNAME>/<REPO>.git
hudson.plugins.git.GitException: Failed to fetch from git@<GITLAB>:<USERNAME>/<REPO>.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:623)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:855)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:880)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1251)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:605)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:514)
at hudson.model.Run.execute(Run.java:1703)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:231)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@<GITLAB>:<USERNAME>/<REPO>.git +refs/heads/*:refs/remotes/origin/*" returned status code 143:
stdout:
stderr:
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1307)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1169)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:257)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:153)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:146)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
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 hudson.remoting.Engine$1$1.run(Engine.java:63)
at java.lang.Thread.run(Thread.java:745)
我们已经添加了 Mac 的 SSH 公钥作为存储库的部署密钥,并且我们使用了 Mac 的 SSH 私钥作为凭据,但由于某种原因,它不起作用。有什么想法吗?
编辑:查看 Mac slave 上的日志,我注意到它提示用户“输入密钥 '/var/folders/92/<RANDOM STRING OF CHARACTERS>/T/ssh<RANDOM STRING OF NUMBERS>key':" 的密码,如果我手动输入 SSH 密钥的密码,它可以工作。但是这个解决方案不是”不适合自动构建系统。
进一步挖掘,如果我真的去'/var/folders/92/<RANDOM STRING>/T/' 文件夹,我会看到一些文件。当 Mac 从机被提示输入密码时,会出现 ssh<RANDOM NUMBERS>key 文件、ssh<DIFF RANDOM NUMBERS>.sh 文件和 pass<OTHER DIFF RANDOM NUMBERS>.sh 文件。 ssh<...>key 文件包含 SSH 私钥,ssh<...>.sh 文件包含使用该私钥的 ssh 命令,pass<...>.sh 文件包含回显 SSH 密码的命令。
【问题讨论】:
-
如果您使用 Jenkins 使用的相同凭据从命令行运行相同的 git fetch 命令会发生什么?
-
它工作得很好。使用 Mac 从站手动克隆存储库没有问题。
标签: macos git ssh jenkins gitlab