使用HTTPS从gitlab CI作业克隆私有仓库,而无需将我的凭据暴露给CLI [英] Cloning a private Repo from gitlab CI job using HTTPS without exposing my credentials into CLI
问题描述
我有一个gitlab ci作业,可以为我做一些工作,但这取决于另一个回购,因此我需要在此工作中克隆另一个回购.我无法使用https克隆,因为gitlab会询问我用户名和密码,并且gitlab ci是非交互式的.
那么如何在gitlab ci作业中使用https克隆gitlab仓库.
提前谢谢.
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.
推荐答案
如果您正在运行gitlab版本8.12或更高版本,则将重新设计权限模型.CI环境变量CI_JOB_TOKEN伴随着这个新的权限模型.高级版GitLab使用此环境变量作为触发器,但是您可以使用它来克隆存储库.
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
这篇关于使用HTTPS从gitlab CI作业克隆私有仓库,而无需将我的凭据暴露给CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!