Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 = [email protected]: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' ([email protected]: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 '[email protected]: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.

like image 264
Netanel Avatar asked Nov 20 '25 00:11

Netanel


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.

like image 59
Rekovni Avatar answered Nov 22 '25 02:11

Rekovni



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!