在詹金斯找不到私人git子模块
-
21-12-2019 - |
题
问题
我正在尝试在詹金斯建立我的应用程序,它位于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中尝试做的事情
- 试图设置其他行为“高级子模块行为”,没有成功。
- 在使用phpunit运行测试之前尝试设置新步骤:
git submodule update --init --recursive
- 试图在我的子模块的项目上设置一个git存储库,而不仅仅是正在测试的主要存储库,没有运气。
所有这些都会导致错误,说明Jenkins无法找到子模块的存储库。
如何解决这个问题?
(用户名,路径和存储库是正确的,我刚刚将它们更改为在此发布)
解决方案
解决了。在我的凭据中,我正在使用直接的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*
. 不隶属于 StackOverflow