[英]Gitlab CI and Git partial clone
I am testing the git partial clone feature on a large monorepo.我正在大型 monorepo 上测试 git 部分克隆功能。 A developer might run the following commands on his machine:
开发人员可能会在他的机器上运行以下命令:
git clone --filter=blob:none --sparse THE_MONOREPO_URL.git
git sparse-checkout init --cone
git sparse-checkout set SOME FOLDERS
This seems to be working well, and I am now trying to get CI up and running in Gitlab.这似乎运作良好,我现在正试图在 Gitlab 中启动并运行 CI。 If I use the default settings in my
.gitlab-ci.yml
file, Gitlab clones the entire monorepo, which takes forever.如果我在
.gitlab-ci.yml
文件中使用默认设置,Gitlab 会克隆整个 monorepo,这需要很长时间。
Gitlab recently added experimental support for partial clones, but is there any support in Gitlab-CI? Gitlab 最近添加了对部分克隆的实验性支持,但是 Gitlab-CI 中是否有任何支持? Is my only option to use
GIT_STRATEGY: none
and then clone everything manually in the before_script
using the commands above?我唯一的选择是使用
GIT_STRATEGY: none
然后使用上面的命令在before_script
中手动克隆所有内容吗?
You can configure GitLab CI to make a shallow clone.您可以配置 GitLab CI 以进行浅克隆。 Go to your project page - Settings - CI/CD, expand General pipelines, and insert a value to Git shallow clone field.
Go 到你的项目页面 - 设置 - CI/CD,展开通用管道,并在 Git 浅克隆字段中插入一个值。
Note that clone --sparse
has already run sparse-checkout init
for you.请注意,
clone --sparse
已经为您运行了sparse-checkout init
。
You can set the git strategy to FETCH, then use https://docs.gitlab.com/ee/ci/yaml/README.html#git-fetch-extra-flags to custom how you fetch/clone your project.您可以将 git 策略设置为 FETCH,然后使用https://docs.gitlab.com/ee/ci/yaml/README.html#yougit-fetch yourflag project
Note that Fetch and Clone strategy both use this flag.请注意,Fetch 和 Clone 策略都使用此标志。 The only different between the 2 strategy is that Clone would attempt to remove what ever left of the repo cached from the previous run before running 'git fetch'
2 策略之间的唯一不同是,Clone 会在运行“git fetch”之前尝试删除前一次运行中缓存的 repo 中的任何内容
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.