Using private GIT repositories
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
The first step is to generate a personal access token: see the github or bitbucket documentation.
Then build an url for the Git Credentials.
The URL for github looks like:
https://<username>:<token>@github.com
while for bitbucket looks like:
https://<username>:<token>@bitbucket.org
where the username
is the username of the account used to generate the token.
Finally add a secret inside an 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
https
clone url without any token.
For instance, if your private repo contains an npm library, the
package.json
would reference it in this way:
{
...
"dependencies": {
"my_super_secret_library": "https://bitbucket.org/myorg/my_super_secret_library.git",
...,
}
...
}