I am trying to download a directory inside of a 'release' branch of a repository from Gitlab. I am using API v4.
The branch includes is of the below structure:
- archive
- outputs
- history-2020-01-01T142535
- history-2020-01-15T142559
- history-2020-02-01T142540
I want to get the "history-2020-02-01T142540" directory.
I can get a ZIP archive of the entire branch...
https://<GITLAB_URL>/api/v4/projects/<PROJECT_ID>/repository/archive.zip?sha=<BRANCH_ID>
How do I get a ZIP archive of only a specific folder within that branch?
This is possible now with this endpoint
curl --header "PRIVATE-TOKEN: <your_access_token>" \
"https://gitlab.com/api/v4/projects/<project_id>/repository/archive?sha=<commit_sha>&path=<path>"
The path
parameter allows you to specify the subfolder path.
Link to gitlab documentation: https://docs.gitlab.com/ee/api/repositories.html#get-file-archive