加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 在Jenkins中找不到私有git子模块

发布时间:2020-12-13 17:26:44 所属栏目:PHP教程 来源:网络整理
导读:问题 我正在尝试在Jenkins中构建我的应用程序,它在Github上的私有仓库中,也有一个私有子模块. 我可以通过设置它的凭据来克隆Jenkins中的私有存储库,但是Jenkins无法克隆子模块,这是失败构建的输出: Started by an SCM changeBuilding in workspace /var/lib
问题

我正在尝试在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尝试过的事情

>尝试设置附加行为“高级子模块行为”,但没有成功.
>尝试使用phpunit运行测试之前设置一个新步骤:

git submodule update –init –recursive

>试图在我的子模块的项目上设置一个git存储库,而不仅仅是正在测试的主存储库,也没有运气.

所有这些都会导致错误,表明Jenkins无法找到子模块的存储库.

有什么想法我怎么解决这个?

(用户名,路径和存储库是正确的,我刚刚将它们更改为在此处发布)

解决方法

解决了.在我的凭证中,我使用的是直接SSH密钥(选项“直接输入”),而不是放入文件中.

我只是将键(公共和私有)放在?/ .ssh中,并将我的凭据更改为选项“From the Jenkins master~ / .ssh”.

问题是子模块没有使用我已经指定给主存储库的凭证,它试图使用默认的ssh密钥(.ssh / id_rsa).

另一个解决方案是将-i my_key传递给git子模块步骤(如果你的密钥不在默认路径中,则只需要这个(?/ .ssh / id_rsa))

另外不要忘记给你的密钥赋予正确的权限,在我的情况下我必须:

chown apache ~/.ssh/id_rsa*
chmod 700 ~/.ssh/id_rsa*

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读