问题
我正在尝试在Jenkins中构建我的应用程序,它是在Github上的私有仓库中,也有一个私有子模块。
我可以通过设置它的凭据来克隆Jenkins中的私有存储库,但Jenkins无法克隆子模块,这是失败构建的输出:
Started by an SCM change
Building in workspace /var/lib/jenkins/jobs/Project/workspace
Fetching changes from the remote Git repository
Fetching upstream changes from git@github.com:user/repogit
using GIT_SSH to set credentials
Checking out Revision 9cc99b67cc676d0ea8ccd489a8327f5c6dbb8d7f (origin/branch)
[workspace] $ /bin/sh -xe /tmp/hudson2710403018107019432.sh
+ git submodule update --init --recursive
Initialized empty Git repository in /var/lib/jenkins/jobs/repository/submodule/.git/
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
Clone of 'git@github.com:user/submodule.git' into submodule path 'repository/submodule/' failed
Build step 'Execute shell' marked build as failure
Discard old builds...
#156 is removed because status FAILURE is not to be kept
Publishing Clover coverage report...
No Clover report will be published due to a Build Failure
Sending e-mails to:
Finished: FAILURE
这是我在Jenkins尝试做的事情
git submodule update --init --recursive
所有这些都会导致错误,表明Jenkins无法找到子模块的存储库。
有关如何解决此问题的任何想法?
(用户名,路径和存储库是正确的,我刚刚将它们更改为在此处发布)
答案 0 :(得分:5)
解决。在我的凭证中,我使用的是直接SSH密钥(选项“直接输入”),而不是放入文件。
我只是将键(公共和私人)放在〜/ .ssh中,并将我的凭据更改为“来自Jenkins master~ / .ssh”选项。
问题是子模块没有使用我为主存储库指定的凭证,它试图使用默认的ssh密钥(.ssh / id_rsa)。
另一个解决方案是将-i my_key传递给git子模块步骤(如果你的密钥不在默认路径中,只需要这个(〜/ .ssh / id_rsa))
另外,不要忘记为您的密钥授予正确的权限,在我的情况下,我必须:
chown apache ~/.ssh/id_rsa*
chmod 700 ~/.ssh/id_rsa*