mda*_*y77 0 gitlab gitlab-ci-runner
我正在尝试在 GitLab 中为项目存储库中包含 Git 子模块的项目创建构建管道。当管道构建作业运行时,它会尝试克隆子模块,但失败并出现以下错误:could not read Username for 'https://gitlab.com': No such device or address
Git 子模块位于同一实例上的同一 GitLab 组中。我已经将这些环境变量添加到 .gitlab-ci.yml 中,如下所示:
---
stages:
- lint
- build
- deploy
variables:
GIT_SUBMODULE_STRATEGY: recursive
GIT_SUBMODULE_FORCE_HTTPS: "true"
Run Code Online (Sandbox Code Playgroud)
这是我运行管道的项目中的 .gitmodules 文件:
[submodule "build-tools"]
path = build-tools
url = https://gitlab.com/core/frontend-dev/build-tools.git
Run Code Online (Sandbox Code Playgroud)
这是该项目的网址:https://gitlab.com/core/frontend-dev/api-service.git
我是否需要将子模块 url 转换为相对 url,因为它们都位于同一个 GitLab 实例中?
我解决了这个问题。解决方案分为两部分。
首先,您必须将 .gitmodules 中的 url 更改为相对的,如下所示:
[submodule "build-tools"]
path = build-tools
url = ../build-tools.git
Run Code Online (Sandbox Code Playgroud)
该 url 与您存储 .gitmodule 的项目相关。因此,如果子模块和项目位于同一组中,则路径将为 ../
第二部分是您必须授予项目管道访问子模块项目的权限。进入用作子模块的项目设置并找到“令牌访问”。它位于“设置->CI/CD->令牌访问”中。在“允许以下项目中的 CI 作业令牌访问此项目”下添加项目的路径。
| 归档时间: |
|
| 查看次数: |
1146 次 |
| 最近记录: |