简体   繁体   English

如何使用 python 脚本在 Gitlab CI 运行器中克隆 gitlab 私有存储库?

[英]How to clone a gitlab private repository in Gitlab CI runner using a python script?

I have a private Gitlab repository.我有一个私人 Gitlab 存储库。 And I want to clone that private repo to gitlab CI runner using a python script.我想使用 python 脚本将该私有仓库克隆到 gitlab CI 运行器。 But the cli asks for username and password input.但是 cli 要求输入用户名和密码。 Since, Gitlab CLI don't take manual input so, how to provide username and password for authentication.由于 Gitlab CLI 不采用手动输入,所以如何提供用户名和密码进行身份验证。

As you can see in the documentation there are several options for authentication.正如您在文档中看到的,有多种身份验证选项。

I usually do not use password and username, because mostly you end up saving your credentials in plaintext somewhere.我通常不使用密码和用户名,因为大多数情况下您最终会将您的凭据以明文形式保存在某个地方。

My preferred way is using a private token.我的首选方式是使用私有令牌。 This descriptions explains how to create a private token on Gitlab 描述解释了如何在 Gitlab 上创建私有令牌

For a general understanding of tokens:对于令牌的一般理解:

  • A token is a secret hash string, noone else beside you should be able to read it令牌是一个秘密 hash 字符串,除了你之外没有其他人应该能够读取它
  • It combines username and password, you'll only need the token for authentication它结合了用户名和密码,您只需要令牌进行身份验证
  • You generally create and manage the tokens on the sites for which you want to use them (in your case a Gitlab server)您通常在要使用它们的站点上创建和管理令牌(在您的情况下为 Gitlab 服务器)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM