How do I handle git submodules with Gitlab CI/CD?

If your repository uses submodules, follow these instructions to configure your .gitmodules and .gitlab-ci.yml to properly use the submodule(s).

TL;DR:

In the .gitmodules:

  • Use relative paths to point to other gitlab projects, eg. url = ../../group/project.git

  • Use full HTTP(S) paths to point to submodules located on other git servers, eg. url = https://gitserver.com/group/project-x.git

In the .gitlab-ci.yml, add GIT_SUBMODULE_STRATEGY: recursive either as a global variable or for any jobs requiring submodules:

variables:
  GIT_SUBMODULE_STRATEGY: recursive
1 Like