我有一个 gitlab ci 工作,可以为我做一些工作,但它依赖于另一个存储库,所以我需要在这个工作中克隆另一个存储库。我无法使用 https 克隆,因为 gitlab 会要求我提供用户名和密码,并且 gitlab ci 是非交互式的。
那么如何在 gitlab ci 作业中使用 https 克隆 gitlab repo。
提前致谢。
I have found a way to authenticate my cloning. First, I navigate to my gitlab account setting then navigate to access tokens tab.
Then create new access token with any name and you can leave expiring date empty (but for security, I have set an expiring date) then choose the right scope you want. In my case, I have read the repo scope.
然后我使用生成的访问令牌使用 https 克隆我的存储库,如下所示
https://oauth2:[email protected] /cdn-cgi/l/email-protection/PATH/TO/YOUR/REPO.git
To prevent CLI from exposing your access token you have to add your access token in CI variables list from gitlab as masked. SO when cloning is executed your access token will not be displayed.
And then will access it as follow
https://oauth2:[email protected] /cdn-cgi/l/email-protection/PATH/TO/YOUR/REPO.git
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)