Search code examples
gitlab-cigit-submodulesgitlab-ci-runner

Gitlab CI does not checkout new updated submodule


I am using Git submodule in my repository. Whenever I update the submodule to a new commit or tag in the repository after committing the changes the pipeline starts and the runner checkouts the repository with the submodule. The problem is that it checkouts the old submodule and not the updated one. But with a new commit or manually starting the pipeline for the same commit the runner checkouts the newly updated submodule meaning it does not checkouts the updated submodule on the first pipeline build but on the next.

I am missing any steps or it is the default behavior?


Solution

  • Updating a submodule repository alone (commit and push) is not enough for its parent repository to know that said submodule has changed.
    By default, the parent repository will keep referencing the old submodule SHA reference.

    You would need to change its .gitmodules to make it follow a branch (you can set a branch).
    gitlab-ci does not seem to support the --remote option (in git submodule update --remote)