GitLab 在 CI 中拉取子模块 [英] GitLab pull submodules inside CI

查看:63
本文介绍了GitLab 在 CI 中拉取子模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 GitLab CI 的 GitLab 项目.该项目还使用子模块,项目及其子模块都在同一个 GitLab 帐户下.

I have a GitLab project that utilises GitLab CI. The project also uses submodules, both the project and it's submodules are under the same GitLab account.

这是我的 .gitmodules 文件

[submodule "proto_contracts"]
    path = proto_contracts
    url = https://gitlab.com/areller/proto_contracts.git

我在 .gitlab-ci.yml 文件中也有这一段

I also have this piece in the .gitlab-ci.yml file

variables:
  GIT_SUBMODULE_STRATEGY: recursive

但是,当我运行 CI 时出现此错误

However, when i run the CI I get this error

fatal: could not read Username for 'https://gitlab.com': No such device or address

项目和子模块都在私有存储库中,因此您可能会被提示进行身份验证,但正如我所提到的,项目和子模块在同一个帐户下,并且运行者的工作之一是克隆原始存储库

Both the project and the submodules are in a private repository so you would expect to be prompted for authentication, but as I've mentioned, the project and the submodule are under the same account and one of the runner's jobs is to clone the original repository

所以奇怪的是它无法到达子模块有办法解决吗?

So it's odd that it's unable to reach the submodule Is there a way around it?

推荐答案

子模块必须使用相对 URL.更新您的 .gitmodules 如下:

You must use relative URLs for submodules. Update your .gitmodules as follow:

    [submodule "proto_contracts"]
        path = proto_contracts
        url = ../../areller/proto_contracts.git

进一步阅读:在 GitLab CI 中使用 Git 子模块 |GitLab 文档

这篇关于GitLab 在 CI 中拉取子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆