I am trying to get gitlab’s CI to work properly with an external submodule.
- I have a submodule in ANOTHER repository, so no relative path.
- I do NOT want to use a SSH key solution.
- I want to use the CI token (CI_JOB_TOKEN).
Documentation is NOT clear because what is possible, or not, has changed and there are texts all over the place with many different approaches and, yet, nothing that fits the basic criteria.
It used to not be possible to pull submodules, with CI, if they had an absolute path, so people came up with various solutions. Then it became possible and there are a few solutions regarding authentication issues. But they all involve doing a clone which is not needed anymore because now we can set the CI to do a recursive pool.
This means that most of the online posts have become irrelevant and outdated and answers are one liners here and there but after a few hours none has worked for me.variables: GIT_SUBMODULE_STRATEGY: recursive
What has worked is to make a global admin key, giving access to everything but this is not a good solution at all.
What I have now is:
variables:
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/".insteadOf "git@gitlab.com:"
- git submodule sync && git submodule update --init
Which, according to Getting GitLab CI to clone private repositories should work.
But it fails with:
fatal: could not read Username for 'https://gitlab.com': No such device or address