Home > Enterprise >  How to retrieve source code from a release on a self-hosted Gitlab instance?
How to retrieve source code from a release on a self-hosted Gitlab instance?

Time:01-18

I've been attempting to get my source code as a tarball file from a self-hosted Gitlab instance using the following command:

curl --header "Private-Token: my-private-token" "http://gitlab.domain.com/path/to/repository/-/archive/release-tag/release-code.tar.gz"

The link points to a source code asset in the release, however the command outputs:

<html><body>You are being <a href="http://gitlab.domain.com/users/sign_in">redirected</a>.</body></html>

What is going wrong here? I would assume the private token, but it has worked in the past for other processes. The link also works fine when entered into a browser...

CodePudding user response:

Tokens are meant to be used within the API; try using the get file archive endpoint

curl --header "PRIVATE-TOKEN: ${TOKEN}" \
"https://gitlab.domain.com/api/v4/projects/project_id/repository/archive.zip?sha=v0.0.2" -o archive-v0.0.2.zip 
  • Related