In complex CI/CD scenarios, we may need to access other resources from GitLab that is out of current project/repository, like cloning another repository, or calling gitlab API to trigger a contiguous job.

These resources are accessible via CI/CD job token.

Clone a Repository Using CI_JOB_TOKEN

1
git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.example.com/<namespace>/<project>

Trigger a Job Using CI_JOB_TOKEN

1
curl --request POST --form token=${CI_JOB_TOKEN} https://gitlab.example.com/api/v4/projects/<project_id>/trigger/pipeline