从Gitlab实例克隆时,Jenkins挂在Mac奴隶上

时间:2014-07-08 18:40:07

标签: macos git ssh jenkins gitlab

我们正在尝试通过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从站上的日志,我注意到它会提示用户“输入密钥'/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密码的命令。

2 个答案:

答案 0 :(得分:2)

原来我需要将SSH密钥添加到Mac的钥匙串中,或者在SSH密钥中删除密码。要添加到Mac上的钥匙串运行ssh-add <SSH PRIVATE KEY FILE>(您可能还需要启用执行eval $(ssh-agent)的ssh-agent)。

答案 1 :(得分:1)

我的猜测是你的Jenkins从属进程运行的用户与你用来从命令行运行git的用户不同。如果是这种情况 - 您需要先批准该用户的初始主机密钥验证,然后才能在Jenkins中运行git。 (你知道 - 第一次与ssh连接时得到的消息:

The authenticity of host '111.11.11.11' can't be established.
RSA key fingerprint is 3f:1b:f4:bd:c5:aa:c1:1f:bf:4e:2e:cf:53:fa:d8:59.
Are you sure you want to continue connecting (yes/no)?