Reputation: 201
I have follow situation: I am doing GitLab CI with private submodule from GitHub, and getting next messages in my pipeline:
fatal: could not read Username for 'https://github.com': No such device or address fatal: clone of 'https://github.com/username/project' into submodule path '/my_gitlab_username/my_gitlab_project' failed
fatal: could not read Username for 'https://github.com': No such device or address fatal: clone of 'https://github.com/username/project' into submodule path '/my_gitlab_username/my_gitlab_project' failed
Failed to clone 'submodule_name' a second time, aborting
How can I set token or something helpful for cloning GitHub private repo?
Upvotes: 0
Views: 1063
Reputation: 1345
Docs taken from gitlab
When you use Git submodules, your project should have a file named .gitmodules
. You might need to modify it to work in a GitLab CI/CD job.
For example, your .gitmodules
configuration might look like the following if:
Your project is located at https://gitlab.com/secret-group/my-project
.
Your project depends on https://gitlab.com/group/project
, which you want to include as a submodule.
You check out your sources with an SSH address like [email protected]:secret-group/my-project.git
.
[submodule "project"]
path = project
url = ../../group/project.git
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.
The above configuration instructs Git to automatically deduce the URL to use when cloning sources. Git uses the same configuration for both HTTPS and SSH. GitLab CI/CD uses HTTPS for cloning your sources, and you can continue to use SSH to clone locally.
For submodules not located on the same GitLab server, use the full URL:
[submodule "project-x"]
path = project-x
url = https://gitserver.com/group/project-x.git
Upvotes: -1
Reputation: 166
To clone repository, you might need to use token:
git config --global credential.helper store
git clone https://your_username:[email protected]/username/private-repo.git
Otherwise use curl api calls
Upvotes: 1