Can anyone post a working example of GitLab CI that has external submodules?

余生长醉 提交于 2019-12-10 11:47:03

问题


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

来源:https://stackoverflow.com/questions/58040183/can-anyone-post-a-working-example-of-gitlab-ci-that-has-external-submodules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!