2

I am testing the git partial clone feature on a large monorepo. 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. If I use the default settings in my .gitlab-ci.yml file, Gitlab clones the entire monorepo, which takes forever.

Gitlab recently added experimental support for partial clones, but is there any support in Gitlab-CI? Is my only option to use GIT_STRATEGY: none and then clone everything manually in the before_script using the commands above?

Touloudou
  • 2,079
  • 1
  • 17
  • 28

2 Answers2

0

You can configure GitLab CI to make a shallow clone. Go to your project page - Settings - CI/CD, expand General pipelines, and insert a value to Git shallow clone field.

1615903
  • 32,635
  • 12
  • 70
  • 99
0

Note that clone --sparse has already run sparse-checkout init for you.

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.

Note that Fetch and Clone strategy both use this flag. 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'