I have a gitlab ci job that does some work for me but it depends on another repo so I need to clone another repo inside this job. I can't use https cloning because gitlab will ask me for user name and password and the gitlab ci is non-interactive.
So how to clone gitlab repo using https inside gitlab ci job.
Thanks in advance.
You can either clone a private Github repository with a password like you normally would with any other online service, or do it with a token if you enabled 2-factor-authentication on your account or your organization uses SAML SSO. Alternatively, you can also clone private Github repo with SSH credentials.
If you want to clone it to a specific folder, just insert the folder address at the end like so: git clone https://<token>@github.com/<username>/<repository.git> <folder> , where <folder> is, you guessed it, the folder to clone it to! You can of course use . , .. , ~ , etc.
If you are running gitlab version 8.12 or later, the permissions model was reworked. Along with this new permission model comes the the CI environment variable CI_JOB_TOKEN. The premium version of GitLab uses this environment variable for triggers, but you can use it to clone repos.
dummy_stage:
script:
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.instance/group/project.git
You should clone that repo using SSH and a read-only deploy key, possibly storing the token in a masked variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With