Sometimes the big projects consists of more than one repository which are usually used as submodules in your main git repository.

The normal setup of a submodule (.gitmodules file) looks like this:

[submodule "project-x"]
  path = project-x
  url = git@gitlab.com:company-x/project-x.git

If you do your submodules configuration in this way you will have to clone all of them manually which is useless.

The right way to  have all submodules cloned recursive is to configure them this way:

[submodule "project-x"]
  path = project-x
  url = ../../project-x.git

After that your .gitlab-ci sould look like this where the key is in the variable GIT_SUBMODULE_STRATEGY set to “recursive”

image: alpine:latest
variables:
  GIT_SUBMODULE_STRATEGY: recursive
stages:
  - build
  - deploy

build_frontend:
  stage: build
  script:
    - ... do the build ...
deploy_production:
  stage: deploy
  script:
    - ... do the deploy ...