During the build process, it might be necessary to access other private repositories containing, for instance, libraries.
In case such repositories do not belong to the same user that can clone the main application codebase, it is possible to use git credentials codebase.
How to use Git Credentials
Then build an url for the Git Credentials.
The URL for GitHub looks like:
while for Bitbucket looks like:
and GitLab looks like:
username is the username of the account used to generate the token.
You cannot add Git credentials for the same provider that your repository is hosted on. For instance, if your repository is hosted on GitHub and you add additional Git credentials for a GitHub user then the additional credentials will be ignored.
Finally add a secret inside an environment
with key called
GIT_CREDENTIALS and for the value use the url created before.
At this point, if you use this environment during a build, you can access your repository specifying the
clone url without any token.
For instance, if your private repo contains an npm library, the
package.json would reference it in this way: