本文介绍了使GitLab CI克隆私有存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有GitLab&安装了GitLab CI来托管和测试我的一些私人仓库。对于此系统下的composer模块,我设置了Satis来解析我的私有软件包。

I have GitLab & GitLab CI set up to host and test some of my private repos. For my composer modules under this system, I have Satis set up to resolve my private packages.

显然,这些私有软件包需要ssh密钥才能克隆它们,而我拥有这个在终端中工作-只要在外壳中添加 ssh-add 添加的密钥,我就可以运行composer install并获取这些软件包。

Obviously these private packages require an ssh key to clone them, and I have this working in the terminal - I can run composer install and get these packages, so long as I have the key added with ssh-add in the shell.

但是,在GitLab CI中运行测试时,如果项目具有以下任何依赖项,则测试将无法完成,因为我的GitLab实例需要身份验证才能获得Dep,并且测试失败说主机密钥验证失败

However, when running my tests in GitLab CI, if a project has any of these dependencies the tests will not complete as my GitLab instance needs authentication to get the deps (obviously), and the test fails saying Host key verification failed.

我的问题是如何设置它,以便当跑步者运行测试它可以在没有密码的情况下向gitlab进行身份验证?我曾尝试在跑步者〜/ .ssh 文件夹中放入无密码的ssh-key,但是该版本甚至不会添加密钥 eval ssh-agent -s 后跟ssh-add似乎失败,表明代理未运行...

My question is how do I set this up so that when the runner runs the test it can authenticate to gitlab without a password? I have tried putting a password-less ssh-key in my runners ~/.ssh folder, however the build wont even add the key, "eval ssh-agent -s" followed by ssh-add seems to fail saying the agent isn't running...

推荐答案

我将其发布为答案,因为其他人还不太清楚和/或没有详细的恕我直言

I'm posting this as an answer since others weren't completely clear and/or detailed IMHO

从GitLab 8.12+开始,假设子模块存储库位于与请求它的服务器相同,您现在可以:

Starting from GitLab 8.12+, assuming the submodule repo is in the same server as the one requesting it, you can now:


  1. 像往常一样使用git子模块设置存储库( git子模块添加git @ somewhere:folder / mysubmodule.git

修改您的。 gitmodules 文件如下

 [submodule "mysubmodule"]
   path = mysubmodule
   url = ../../group/mysubmodule.git

其中 ../../ group / mysubmodule.git 是从存储库到子模块的相对路径。

where ../../group/mysubmodule.git is a relative path from your repository to the submodule's one.

将以下行添加到 gitlab-ci.yml

 variables:
   GIT_SUBMODULE_STRATEGY: recursive

指示运行程序之前获取所有子模块

to instruct the runner to fetch all submodules before the build.

注意:如果您的跑步者似乎忽略了 GIT_SUBMODULE_STRATEGY 指令,您可能应该考虑。

Caveat: if your runner seems to ignore the GIT_SUBMODULE_STRATEGY directive, you should probably consider updating it.

(来源:)

这篇关于使GitLab CI克隆私有存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 16:22