我有两个 GitLab 存储库,它们都在我在 GitLab 中的用户名下。他们俩都是私有(private)的。一个存储库是另一个存储库的依赖项,但后者不使用子模块。相反,它将包安装到 docker 镜像。
我已阅读 this .但是,我不想配置任何 token 或其他复杂的东西。
有什么简单友好的方法可以让我的私有(private) repo 对我自己透明吗?
最佳答案
查看 CI_JOB_TOKEN
, 是 predefined environment variables 之一GitLab CI/CD 无需任何规范即可使用。基于official documents CI_JOB_TOKEN
描述如下:
Token used for authenticating with the GitLab Container Registry and downloading dependent repositories
并以此为基础document :
The Job environment variable
CI_JOB_TOKEN
can be used to authenticate any clones of dependent repositories. For example:git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/<user>/<mydependentrepo>.git
因此,您可以通过在
gitlab-ci.yml
中所需的每个作业的脚本部分中使用上述代码,将您的依赖存储库克隆到当前管道中。文件。 是否使用 CI_JOB_TOKEN
都可以正常工作而不是您的密码或任何 token ,无需担心gitlab-ci-token
在网址中。您还可以使用每个所需的用户名来代替它。
关于docker - 使用同一作者从 gitlab CI 下载另一个私有(private)存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59508583/