Check CI_JOB_TOKEN
, It is one the predefined environment variables of GitLab CI/CD which can be used without any specification needed. Base on official documents CI_JOB_TOKEN
is described as follows:
Token used for authenticating with the GitLab Container Registry and downloading dependent repositories
And base on this document:
The Job environment variable CI_JOB_TOKEN
can be used to authenticate any clones of dependent repositories. For example:
git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/<user>/<mydependentrepo>.git
So you can clone your dependent repository into the current pipeline by using above code in the script part of every job you want in gitlab-ci.yml
file.
It works fine whether it uses CI_JOB_TOKEN
instead of your password or any tokens and there is no need to worry about gitlab-ci-token
in the URL. You can also put every desired user name instead of it.