GitLab在CI中拉出子模块

are*_*ler 4 git-submodules gitlab gitlab-ci gitlab-ci-runner

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

这是我的.gitmodules档案

[submodule "proto_contracts"]
    path = proto_contracts
    url = https://gitlab.com/areller/proto_contracts.git
Run Code Online (Sandbox Code Playgroud)

我在.gitlab-ci.yml文件中也有这部分

variables:
  GIT_SUBMODULE_STRATEGY: recursive
Run Code Online (Sandbox Code Playgroud)

但是,当我运行配置项时,出现此错误

fatal: could not read Username for 'https://gitlab.com': No such device or address
Run Code Online (Sandbox Code Playgroud)

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

在此处输入图片说明

因此,奇怪的是它无法到达子模块。有没有解决的办法?

小智 7

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

    [submodule "proto_contracts"]
        path = proto_contracts
        url = ../../areller/proto_contracts.git
Run Code Online (Sandbox Code Playgroud)

进一步阅读:在GitLab CI中使用Git子模块| 亚搏体育app文件

  • 好的!但是,如果有相对 git 路径,那么我如何在本地使用子模块? (3认同)