mistiru
mistiru

Reputation: 3376

Clone external private submodule with deploy token from Gitlab-CI

I have a repository repoB on a private server serverB, and get a deploy token (user + password) from it.
This repository is used as a submodule in the project I'm trying to configure.

In this project, I want to be able to init this submodule during the Gitlab-CI.

My .gitmodules is:

[submodule "repoB"]
    path = repoB
    url = https://serverB/groupB/repoB.git

And I have in my .gitlab-ci.yml:

test_build:
    variables:
        GIT_SUBMODULE_STRATEGY: recursive

Actually, the error I get is the following (group: japan7, project: nanachan, repoB: karaneko, serverB: git.inpt.fr)

Updating/initializing submodules recursively...
Synchronizing submodule url for 'karaneko'
Cloning into '/builds/japan7/nanachan/karaneko'...
fatal: could not read Username for 'https://git.inpt.fr': No such device or address
fatal: clone of 'https://git.inpt.fr/japan7/karaneko.git' into submodule path '/builds/japan7/nanachan/karenko' failed
Failed to clone 'karaneko'. Retry scheduled
Cloning into '/builds/japan7/nanachan/karaneko'...
fatal: could not read Username for 'https://git.inpt.fr': No such device or address
fatal: clone of 'https://git.inpt.fr/japan7/karaneko.git' into submodule path '/builds/japan7/nanachan/karenko' failed
Failed to clone 'karaneko' a second time, aborting
ERROR: failed: exit code 1

I suppose that I should put the deploy token user and password in the project secrets (in Settings −> CI / CD −> Variables) but I could not find the name of these variables, nor any help to solve this particular case.

How should I proceed?
Thank you in advance for your help!

Upvotes: 8

Views: 9962

Answers (1)

Celly
Celly

Reputation: 115

I solved same issue using deploy token. Just added submodule with deploy token and everything on CI runs ok.

http://<username>:<deploy_token>@gitlab.example.com/tanuki/awesome_project.git

And .gitmodules looks like:

[submodule "tanuki/awesome_project"]
    path = tanuki/awesome_project
    url = https://<username>:<deploy_token>@gitlab.example.com/tanuki/awesome_project.git

https://docs.gitlab.com/ee/user/project/deploy_tokens/

Upvotes: 9

Related Questions