Use Gitlab's CI/CD with submodules - cannot run ssh

Viewed 2833

I have a two private repositories: MyProject, MyProjetUtils.

My project uses the MyProjectUtils as a submodule.

My .gitsubmodules looks like this:

[submodule "MyProjetUtils"]
    path = MyProjetUtils
    url = git@gitlab.com:MyCompany/MyProjetUtils.git

My .gitlab-ci.yml file looks like this:

default:
  image: python:latest
variables:
  GIT_SUBMODULE_STRATEGY: recursive
all_test:
  stage: test
  script:
    - apt-get update
    - pip install -r requirements.txt
    - python tests/run_tests.py

The error I'm getting during the job run:

Updating/initializing submodules recursively with git depth set to 50...
Submodule 'MyProjetUtils' (git@gitlab.com:MyCompany/MyProjetUtils.git) registered for path 'MyProjetUtils'
Cloning into '/builds/MyCompany/MyProject/MyProjetUtils'...
error: cannot run ssh: No such file or directory
fatal: unable to fork
fatal: clone of 'git@gitlab.com:MyCompany/MyProjetUtils.git' into submodule path '/builds/MyCompany/MyProject/MyProjetUtils' failed
Failed to clone 'MyProjetUtils'. Retry scheduled

This error occur before the test stage. I've looked for answer here, and here but could not find an answer.

1 Answers

The first link you posted has the solution you are looking for:

When your submodule is on the same GitLab server, you should use relative URLs in your .gitmodules file. Then you can clone with HTTPS in all your CI/CD jobs. You can also use SSH for all your local checkouts.

Assuming that your submodules are in the same group, update your .gitmodules to use a relative URL.

ie:

[submodule "MyProjetUtils"]
    path = MyProjetUtils
    url = ../../MyCompany/MyProjetUtils.git

May need to update ../../ to work for your groups.

Related