当从Gitlab实例克隆时,Jenkins挂在Mac slave上



我们正在尝试通过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 slave被提示输入密码短语时,会出现一个ssh<RANDOM NUMBERS>key文件、一个ssh<DIFF RANDOM NUMBERS>.sh文件和一个pass<OTHER DIFF RANDOM NUMBERS>.sh文件。ssh<...>key文件包含SSH私钥,ssh<...>.sh文件包含使用该私钥的SSH命令,pass<...>.sh文件包含回显SSH口令的命令。

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

我的猜测是你的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)? 

)

相关内容

  • 没有找到相关文章