[英]How to clone a private git repository using Gitlab CI
Scenario: I've created two repositories inside my GitLab account: ' work ' & ' project '.场景:我在我的 GitLab 帐户中创建了两个存储库:“工作”和“项目”。 There are multiple branches in each of the following repos.
以下每个 repos 中都有多个分支。 I'm currently in the project repo and have created the
.gitlab-ci.yml
file.我目前在项目仓库中并创建了
.gitlab-ci.yml
文件。
Task: I want to copy two files 'A' & 'B' from the feature branch of ' work ' repository to the current location (ie, in the root of my project repository).任务:我想将两个文件“A”和“B”从“工作”存储库的功能分支复制到当前位置(即,在我的项目存储库的根目录中)。
Thanks in advance:)提前致谢:)
It's very easy, just add it to your script section - git clone https://user:password@gitlab.com/group/project.git
这很简单,只需将其添加到您的脚本部分
- git clone https://user:password@gitlab.com/group/project.git
Or to download specific files - curl --header 'Private-Token: <your_access_token>' https://gitlab.com/api/v4/projects/:id/repository/files/:filename\?ref\=:ref
或下载特定文件
- curl --header 'Private-Token: <your_access_token>' https://gitlab.com/api/v4/projects/:id/repository/files/:filename\?ref\=:ref
Also it will be a great practice to add Private-Token to project masked varible将 Private-Token 添加到项目掩码变量中也是一个很好的做法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.