Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clone a private git repository using Gitlab CI

Scenario: I've created two repositories inside my GitLab account: 'work' & 'project'. There are multiple branches in each of the following repos. I'm currently in the project repo and have created the .gitlab-ci.yml file.

Task: I want to copy two files 'A' & 'B' from the feature branch of 'work' repository to the current location (i.e., in the root of my project repository).

Thanks in advance :)

like image 289
MOHIT BHATT Avatar asked May 04 '26 19:05

MOHIT BHATT


1 Answers

It's very easy, just add it to your script section - git clone https://user:[email protected]/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

Also it will be a great practice to add Private-Token to project masked varible

You can get access token here access_token

like image 131
Makariy Avatar answered May 06 '26 15:05

Makariy