docker - 使用同一作者从 gitlab CI 下载另一个私有(private)存储库

标签 docker gitlab gitlab-ci docker-image

我有两个 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/

相关文章:

git - 尽管删除了 .gitignore 仍然没有忽略文件

git - 如何在 gitlabhq 中通过 Web 界面在线接受 merge 请求?

node.js - 尝试让 Gitlab CI 运行 NPM 和 Gulp 时出错

docker - 兼容模式不支持以下部署子键

docker - 默认情况下未启用容器监视

nginx - 如果设置了 external_url,Gitlab docker 将无法工作

Gitlab ci 问题,使用触发器将工件传递到下游管道并需要关键字

gitlab-ci - 如何在windows、linux和macos上运行ci?

docker - Google容器注册表:推送报告 “Repository does not exist”

tomcat的docker文件