我正在尝试在我的 Mac Mini 上设置 Jenkins,以便从 BitBucket 中提取我的 iOS 项目源代码并自动构建它。我已经解决了生成 ssh 密钥、将它们上传到 BitBucket、通过控制台执行 ssh 连接以将主机添加到众所周知的列表中的主要众所周知的问题(您可以找到我的所有冒险经历这里和这里)。现在,我的系统中有 3 个用户:A、B 和 Shared。当我安装 Jenkins 时,它会自动将自己置于 Shared 中,但我使用用户 A 生成了 ssh 密钥。因此,为了清楚起见,在 A 主目录中有一个包含公钥和私钥的 .ssh 目录。
当我尝试运行 Jenkins 作业时收到以下错误消息:
Started by user anonymous
Building in workspace /Users/Shared/Jenkins/Home/jobs/myprojectAdHocBuild/workspace
Checkout:workspace / /Users/Shared/Jenkins/Home/jobs/myprojectAdHocBuild/workspace - hudson.remoting.LocalChannel@625cb0bb
Using strategy: Default
Cloning the remote Git repository
Cloning repository [email protected]:myuser/myproject.git
git --version
git version 1.8.0
ERROR: Error cloning remote repo 'origin' : Could not clone [email protected]:myuser/myproject.git
hudson.plugins.git.GitException: Could not clone [email protected]:myuser/myproject.git
at hudson.plugins.git.GitAPI.clone(GitAPI.java:271)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1036)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:978)
at hudson.FilePath.act(FilePath.java:851)
at hudson.FilePath.act(FilePath.java:824)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:978)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1134)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1325)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
at hudson.model.Run.execute(Run.java:1516)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:236)
Caused by: hudson.plugins.git.GitException: Command "/usr/local/git/bin/git clone --progress -o origin [email protected]:myuser/myproject.git /Users/Shared/Jenkins/Home/jobs/myprojectAdHocBuild/workspace" returned status code 128:
stdout: Cloning into '/Users/Shared/Jenkins/Home/jobs/myprojectAdHocBuild/workspace'...
stderr: Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:885)
at hudson.plugins.git.GitAPI.access$000(GitAPI.java:40)
at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:267)
at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:246)
at hudson.FilePath.act(FilePath.java:851)
at hudson.FilePath.act(FilePath.java:824)
at hudson.plugins.git.GitAPI.clone(GitAPI.java:246)
... 14 more
Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1048)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:978)
at hudson.FilePath.act(FilePath.java:851)
at hudson.FilePath.act(FilePath.java:824)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:978)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1134)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1325)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
at hudson.model.Run.execute(Run.java:1516)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:236)
如您所见,当 Hudson 尝试运行 GIT 命令时,它会失败。奇怪的是,如果我尝试运行
/usr/local/git/bin/git clone --progress -o origin [email protected]:myuser/myproject.git /Users/Shared/Jenkins/Home/jobs/myprojectAdHocBuild/workspace
在我的控制台中,它工作正常(在修复了与文件夹写入权限相关的小问题之后修改模式)
我发现了一个邮政报告了类似的错误,其中列出了许多可能的选项,但我不确定如何在控制台上正确执行这些操作。看起来 Jenkins 正在尝试使用没有权限从我的 .ssh 目录中检索相应密钥的用户运行命令。不太确定。也许这个输出可以提供帮助:
MacMini:~ myuser$ ps axu | grep "/jenkins"
myuser 11660 0.0 4.6 2918124 97096 ?? S 6:59pm 1:05.63 /usr/bin/java -jar /Users/myuser/Library/Caches/org.jenkins-ci.jenkins/jenkins.war
jenkins 9896 0.0 9.0 2939824 188552 ?? Ss 4:06pm 17:55.91 /usr/bin/java -jar /Applications/Jenkins/jenkins.war
myuser 11930 0.0 0.0 2432768 588 s000 S+ 10:28am 0:00.00 grep /jenkins
MacMini:~ myuser$ ps axu | grep tomcat
myuser 11932 0.0 0.0 2432768 588 s000 S+ 10:28am 0:00.00 grep tomcat
MacMini:~ myuser$
我真的希望解决这个问题,因为我想用我在网上找到的所有信息来写一个非常详细的教程。