Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab pull submodules inside CI

I have a GitLab project that utilises GitLab CI. The project also uses submodules, both the project and it's submodules are under the same GitLab account.

Here is my .gitmodules file

[submodule "proto_contracts"]
    path = proto_contracts
    url = https://gitlab.com/areller/proto_contracts.git

I also have this piece in the .gitlab-ci.yml file

variables:
  GIT_SUBMODULE_STRATEGY: recursive

However, when i run the CI I get this error

fatal: could not read Username for 'https://gitlab.com': No such device or address

Both the project and the submodules are in a private repository so you would expect to be prompted for authentication, but as I've mentioned, the project and the submodule are under the same account and one of the runner's jobs is to clone the original repository

enter image description here

So it's odd that it's unable to reach the submodule Is there a way around it?

like image 641
areller Avatar asked Feb 17 '18 20:02

areller


People also ask

Does git pull include submodules?

Pulling with submodules. Once you have set up the submodules you can update the repository with fetch/pull like you would normally do. To pull everything including the submodules, use the --recurse-submodules and the --remote parameter in the git pull command .

What is Gitlab submodule?

all tiers. Use Git submodules to keep a Git repository as a subdirectory of another Git repository. You can clone another repository into your project and keep your commits separate.

Why you should not use git submodules?

This is because of some major drawbacks around git submodules, such as being locked to a specific version of the outer repo, the lacking of effective merge management, and the general notion that the Git repository itself doesn't really know it's now a multi-module repository.

Is using git submodules a good idea?

Git submodules may look powerful or cool upfront, but for all the reasons above it is a bad idea to share code using submodules, especially when the code changes frequently. It will be much worse when you have more and more developers working on the same repos.


1 Answers

You must use relative URLs for submodules. Update your .gitmodules as follow:

    [submodule "proto_contracts"]
        path = proto_contracts
        url = ../../areller/proto_contracts.git

Further reading: Using Git submodules with GitLab CI | GitLab Docs

like image 158
ilia Avatar answered Oct 06 '22 23:10

ilia