如何在 CI 构建中访问多个存储库? [英] how to access multiple repositories in CI build?

查看:21
本文介绍了如何在 CI 构建中访问多个存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个由多个(非公共)存储库组成的项目.

We have a project that is composed of multiple (non-public) repositories.

要构建整个项目,构建系统需要拥有所有存储库(master 分支)的文件.

To build the whole project, the build system needs to have the files of all repositories (master branches).

有没有一种方法可以配置 GitLab CI 以提供我需要的存储库?

Is there a way I can configure GitLab CI to provide the repositories I need?

我想我可以在 CI 构建期间执行 git fetch 或类似操作,但是如何处理身份验证呢?

I guess I could do a git fetch or similar during the CI build, but how to deal with authentication then?

推荐答案

您可以为所有项目添加部署密钥.然后在运行器上配置部署密钥的私钥.在构建过程中使用普通的 git 命令来克隆运行器上的存储库.这可能需要对跑步者进行一些配置,但它应该可以工作.

You can add a deploy key to all projects. Then configure the deploy key's private key on the runner(s). Use normal git commands in your build process to clone the repositories on the runner. This may require a bit of configuration on your runners, but it should work.

您可以生成一个 SSH 密钥对并在所有运行器上使用它,也可以为每个运行器生成一个密钥对.要生成 SSH 密钥对,请遵循 SSH 密钥 文档.私钥应放置在 'gitlab-runner' 用户的 .ssh 目录中,以便 git 命令可以在克隆时显示它.公钥应作为部署密钥添加到 GitLab 项目中.在项目设置中添加部署密钥 -> '部署密钥'.

You can either generate one SSH key pair and use that on all runners or generate one key pair per runner. To generate an SSH key pair follow SSH key documentation. The private key should be placed in 'gitlab-runner' user's .ssh directory so the git command can present it at clone time. The public key should be added to the GitLab project as a deploy key. Add a deploy key in the project settings -> 'Deploy Keys'.

这篇关于如何在 CI 构建中访问多个存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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