0

I'm new to Gitlab CICD. We have a repository which has two submodules registered with SSH urls. In the CICD job, it failed to clone the submodules because of Host key verification failed. I think the job environment's ssh public key is not registered in some Gitlab account, but I have no clue how to add the public key to which account.

The .gitsubmodules is like:

[submodule "xfoo"]
    path = xfoo
    url = git@gitlab.com:a/xfoo.git
[submodule "xbar"]
    path = xbar
    url = git@gitlab.com:a/xbar.git

The .gitlab-ci.yml is like:

variables:
    GIT_SUBMODULE_STRATEGY: recursive 

test:
  script:
    - bash ./foo.sh

cpplint:
  script:
    - bash ./bar.sh

In foo.sh and bar.sh there are no git commands. I think there's a standard setup for this case but just can't find out how.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53
  • 1
    "Host key verification failed" is about **host** key, not user key. https://stackoverflow.com/a/13364116/7976758, https://stackoverflow.com/search?q=%5Bgit%5D+Host+key+verification+failed . `ssh-keygen -R gitlab.com; ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts` – phd Jan 26 '21 at 06:40
  • @phd thanks for your comment. Where should I run the command? In `.gitlab-ci.yml`? I'm confused. – ElpieKay Jan 26 '21 at 09:18
  • 1
    Yes but they must be run before pulling submodules; so you need to rewrite your `.gitlab-ci.yml` to update host key then clone the main repository with submodules and not rely on Gitlab runner automatically pull submodules. – phd Jan 26 '21 at 10:47

0 Answers0