Jenkins中找不到私人git子模块

Jenkins中找不到私人git子模块

本文介绍了Jenkins中找不到私人git子模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题



我试图在Jenkins中构建我的应用程序,并且它在Github上的私人回购中,也有一个私人的子模块。

我可以通过设置凭据来克隆Jenkins中的私有存储库,但Jenkins无法克隆子模块,下面是失败的构建的输出:

 由SCM更改启动
在工作空间/ var / lib / jenkins / jobs / Project / workspace中建立
从远程Git存储库获取更改
[email protected]获取上游更改:user / repogit
使用GIT_SSH设置凭据
检出版本9cc99b67cc676d0ea8ccd489a8327f5c6dbb8d7f(origin / branch)
[工作空间] $ / bin / sh -xe /tmp/hudson2710403018107019432.sh
+ git子模块更新--init --recursive
在/ var / lib / jenkins / jobs / repository / submodule / .git /
错误:找不到存储库。
致命:远程端意外挂起
将'[email protected]:user / submodule.git'克隆到子模块路径'repository / submodule /'中失败
构建步骤'Execute shell '标记的构建失败
丢弃旧的构建...
#156被删除,因为状态FAILURE不被保留
发布三叶草覆盖报告...
无Clover报告将由于构建失败而被发布
发送电子邮件到:
完成:FAILURE






  • 尝试设置其他行为高级子模块行为,但没有成功。
  • 尝试在使用phpunit运行测试之前设置一个新步骤:



git submodule update --init --recursive




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



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



任何想法,我怎么能解决这个问题?



(用户名,路径和存储库是正确的,我只是改变他们在这里发布) b $ b

解决方案

解决。在我的证书中,我使用了一个直接的SSH密钥(选项直接输入),而不是放入文件中。



我刚刚把密钥私人)in〜/ .ssh,并将我的凭据更改为选项从Jenkins master〜/ .ssh。

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



另一个解决方案是通过 - 我my_key到git子模块的步骤(只有当你的密钥不在默认路径(〜/ .ssh / id_rsa)时才需要)

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

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


The problem

I'm trying to build my application in Jenkins, and it is on a private repo on Github, also there's a private submodule.

I can clone the private repository in Jenkins by setting up it's credentials, but Jenkins can't clone the submodule, here's the output of a failed build:

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 [email protected]: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 '[email protected]: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

Here's what I've tried to do in Jenkins

  • Tried to set the Additional behavior "Advanced sub-module behavior", with no success.
  • Tried to set up a new step before running the tests with phpunit:

git submodule update --init --recursive

  • Tried to set a git repository on the project of my submodule too, not just the main repository that is being tested, no luck too.

All of them causes the error that says that Jenkins can't find the repository of the submodule.

Any ideas of how can I solve this?

(The username, paths and repositories are correct, I've just changed them to post here)

解决方案

Solved. In my credential I was using a direct SSH key (option "Enter directly"), instead of putting into a file.

I've just put the keys (public and private) in ~/.ssh, and changed my credentials to the option "From the Jenkins master ~/.ssh".

The problem was that the submodule wasn't using the credential that I've specified to the main repository, it was trying to use the default ssh key (.ssh/id_rsa).

Another solution is to pass -i my_key to the git submodule step (only need this if your key isn't in the default path (~/.ssh/id_rsa) )

Also don't forget to give the correct permissions to your keys, in my case I had to:

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

这篇关于Jenkins中找不到私人git子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 03:33