简体   繁体   中英

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

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

在此处输入图像描述


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.

For public repository,

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM