Skip to content
GitLab
Next
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    Projects Groups Snippets
  • Sign up now
  • Login
  • Sign in / Register
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 46,781
    • Issues 46,781
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,539
    • Merge requests 1,539
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLabGitLab
  • Issues
  • #28978
Closed
Open
Issue created May 24, 2019 by Pavel Kozlov@Win32Sector

Download a release asset archive from GitLab via curl redirects to login page

Summary

Im trying to download release from GitLab using curl but it keeps getting redirected to the signin page.

How can I do this?

I have tried the following with no luck:

curl --header "PRIVATE-TOKEN: XXXXXXXXX" "https://gitlab2.mydomain.com/group/project/-/archive/v0.0.5/test-v0.0.5.zip"
### Steps to reproduce

If I try to download tarball from release page, from UI it accessible with link https://gitlab2.mydomain.com/group/project/uploads/d52e8a2bf2a406face2f949d875504b9/test-v0.0.5.zip

curl --header "PRIVATE-TOKEN: XXXXXXXXX" "https://gitlab2.mydomain.com/group/project/uploads/d52e8a2bf2a406face2f949d875504b9/test-v0.0.5.zip"

I receive this:

<html><body>You are being <a href="https://gitlab2.mydomain.com/users/sign_in">redirected</a>.</body></html>

My Gitlab-CI version is 11.10.4

Preferred approach

You can download the archive using the get file archive endpoint from the Repository API, you can specify a sha as a query parameter which can be a branch, tag or commit sha.

$ curl --header "PRIVATE-TOKEN: ${GITLAB_PRIVATE_TOKEN}" \
"https://gitlab.com/api/v4/projects/27579160/repository/archive.zip?sha=v0.0.2" -o ./out/gitlab-v0.0.2.zip 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1602  100  1602    0     0   4161      0 --:--:-- --:--:-- --:--:--  4161

zipinfo out/gitlab-v0.0.2.zip
Archive:  out/gitlab-v0.0.2.zip
Zip file size: 2628 bytes, number of entries: 5
warning [out/gitlab-v0.0.2.zip]:  1026 extra bytes at beginning or within zipfile
  (attempting to process anyway)
drwx---     0.0 fat        0 bx stor 21-Jun-21 11:06 release-test-v0.0.2-d10853040716a6a6cd408cdc0b3b818a261e785c/
-rw----     0.0 fat      506 tx defN 21-Jun-21 11:06 release-test-v0.0.2-d10853040716a6a6cd408cdc0b3b818a261e785c/.gitlab-ci.yml
drwx---     0.0 fat        0 bx stor 21-Jun-21 11:06 release-test-v0.0.2-d10853040716a6a6cd408cdc0b3b818a261e785c/cmd/
-rw----     0.0 fat       73 tx defN 21-Jun-21 11:06 release-test-v0.0.2-d10853040716a6a6cd408cdc0b3b818a261e785c/cmd/main.go
-rw----     0.0 fat       57 tx stor 21-Jun-21 11:06 release-test-v0.0.2-d10853040716a6a6cd408cdc0b3b818a261e785c/go.mod
5 files, 636 bytes uncompressed, 390 bytes compressed:  38.7%

Screenshots from private project

Screen_Shot_2021-06-21_at_2.45.40_pm

Screen_Shot_2021-06-21_at_2.44.34_pm

Edited Jun 28, 2021 by Jaime Martinez
Assignee
Assign to
Time tracking