In certain cases, you might need to pull a git submodule from a private repository into your Code Studio project.
This tutorial demonstrates how to authenticate with a private GitHub repository and pull the git submodule into your Build Code job.
In Select scopes, select all items under repo.
To authenticate with GitHub, use before_script to hook into the Build Code job. To use before_script, you require a custom gitlab-ci.yml file.
Add the GITHUB_TOKEN
environment variable to Code Studio and set its value to the token that you copied from GitHub.
For more information, see Adding environment variables.
Add a before_script to the Build Code job in your project’s gitlab-ci.yml
file:
"Build Code":
before_script:
- |
# Manually trigger the submodule update
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf [email protected]:
git submodule update --init --recursive
While defining git submodules in the .gitmodules
file or in the git submodule add
command, use SSH repository URLs if you use SSH URLs for local development. The pipeline replaces the SSH URLs with HTTPS URLs to authenticate with GitHub.
If this content did not answer your questions, try searching or contacting our support team for further assistance.
Mon Jul 15 2024 06:24:06 GMT+0000 (Coordinated Universal Time)