StoneThrow
StoneThrow

Reputation: 6255

How can I download gitlab CI/CD artifacts with curl?

Our gitlab CI/CD web interface lets us download "artifacts" (e.g. executables, shared libraries) after a successful run, as in the screenshot below:

enter image description here


Question: Is there a way the artifact can be downloaded from a shell? (solution using curl is preferred)

The "Copy Link Location" right-click menu option gives me something like https://git.my_company.com/namespace/project/-/jobs/987134/artifacts/download so I tried the following:

$ curl -O -L https://git.my_company.com/namespace/project/-/jobs/987134/artifacts/download

But that doesn't download the right thing: it gives me a vomit of html, but I'm expecting a .zip file.

If I try to download the file from the web UI, the filename defaults to artifacts.zip, so I also tried:

$ curl -O -L https://git.my_company.com/namespace/project/-/jobs/987134/artifacts/download/artifacts.zip

That does create a file named artifacts.zip but it's still not the expected file: it's still html, though different from the first described attempt.

Upvotes: 8

Views: 28157

Answers (2)

Sergio Tanaka
Sergio Tanaka

Reputation: 1435

Your answer is described here: https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html#downloading-artifacts

The structure of the URL to download the whole artifacts archive is the following:

https://example.com/<namespace>/<project>/-/jobs/artifacts/<ref>/download?job=<job_name>

Upvotes: 2

Bogota
Bogota

Reputation: 391

For public repository,

Go to Settings > General > Permissions > Pipelines must be "Everyone with access".

Upvotes: 1

Related Questions