【发布时间】:2015-04-24 17:31:40
【问题描述】:
我正在使用 bitbucket 和 Jenkins 进行构建。我的项目有一个子模块,需要在构建过程中签出。我正在使用的顶级 git 存储库运行良好。它使用具有 SSH 访问权限的部署密钥将其从 bitbucket 中提取出来。我在两个存储库上都有相同的部署密钥。我还让我的子模块相对于我的项目定义:
[submodule "platform/web-app/WEB-INF/learning"]
path = platform/web-app/WEB-INF/learning
url = ./../xxxxxxxx.git
但是,当 Jenkins 构建项目时,它会拉下顶级存储库并在子模块期间失败。 Jenkins 正在使用 EC2 插件构建它,因此它构建在按需启动的从属盒上。我试图在盒子上手动执行 git,但它以同样的方式失败。我不完全理解 ssh 密钥是如何被推到盒子上的,但我不明白如何调试它。为什么这对一个模块有效,但对子模块无效?
这是输出:
FATAL: Command "git submodule update --init --recursive" returned status code 1:
stdout: Cloning into 'platform/web-app/WEB-INF/learning'...
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Clone of 'git@bitbucket.org:xxxxxxxx/xxxxxxx.git' into submodule path 'platform/web-app/WEB-INF/learning' failed
hudson.plugins.git.GitException: Command "git submodule update --init --recursive" returned status code 1:
stdout: Cloning into 'platform/web-app/WEB-INF/learning'...
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Clone of 'git@bitbucket.org:xxxxxxxx/xxxxxx.git' into submodule path 'platform/web-app/WEB-INF/learning' failed
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1148)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1125)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1121)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:937)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.submoduleUpdate(CliGitAPIImpl.java:598)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.submoduleUpdate(CliGitAPIImpl.java:579)
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 hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:299)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:280)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:239)
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 java.lang.Thread.run(Thread.java:744)
【问题讨论】:
-
会不会是因为stackoverflow.com/a/18912392/6309?还是stackoverflow.com/questions/19550590/…? (即用于 Jankins 的专用帐户没有具有正确私有/公共 ssh 密钥的
~/.ssh/) -
此外,此线程可以帮助突出 Jenkins 连接到 Bitbucket 存储库所需的步骤:answers.atlassian.com/questions/85436/…
-
可能是这样,但这是一台 ec2 机器,它会启动以执行构建,因此每次都会删除盒子的状态。如果它没有〜/ .ssh,但它没有,它怎么能毫无问题地检查初始回购然后在子模块上失败?如果没有.ssh,现在如何工作?
-
那么这就是你的问题。也许最初的 repo 不使用 ssh url,而是使用 https 的,允许公共匿名(未经身份验证)访问。而子模块在父仓库的
.gitmodules中注册了一个ssh url。 -
我已经确认配置设置为使用 ssh。从日志中:使用 GIT_SSH 设置凭据 Jenkins Bitbucket 访问密钥。它说了两次,这让我觉得它使用相同的密钥来访问子模块 repo。
标签: git amazon-ec2 jenkins bitbucket jenkins-plugins