0
votes

ever time i try and download my artifact from GitLab i seen to get the html in a file rather than the xip files it's self.

I have found loads of similar stuff on here but none of the solutions work.

i have tried -l, -O -o changed the oupt file using --ouptput filename.zip, and it always download an html file.

link...

https://gitlab.com/dafabe/example/-/jobs/artifacts/master/download?job=build

how do i change the command so it downloads the actual file?

full command :

curl  https://gitlab.com/dafabe/example/-/jobs/artifacts/master/download?job=build --output filename.zip

tried this with an access toke setup

curl 'https://gitlab.com/dafabe/example/-/jobs/artifacts/master/raw/build/hello?job=build&private_token=<private token here>'

I get this responce...

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

most recent attempt and results...

ubuntu-trusty-64:~/stuff$ curl -L -H "PRIVATE-TOKEN:> xxxxx" https://gitlab.com/dafabe/example/-/jobs/artifacts/master/download?job=build --output filename.zip % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 98 100 98 0 0 189 0 --:--:-- --:--:-- --:--:-- 189 0 0 0 19509 0 0 23717 0 --:--:-- --:--:-- --:--:-- 168k vagrant@vagrant-ubuntu-trusty-64:~/stuff$ ls filename.zip vagrant@vagrant-ubuntu-trusty-64:~/stuff$ file -b filename.zip HTML document, UTF-8 Unicode text, with very long lines vagrant@vagrant-ubuntu-trusty-64:~/stuff$

1
You need to log in to Gitlab with cURL. What you're downloading is the HTML of the login page. See the following answer: stackoverflow.com/questions/47948887/login-to-gitlab-using-curlEduard Itrich

1 Answers

2
votes

This could be an authentication problem as someone mentioned in the comments (and in that case you can for example pass your personal token in the header request).

If your project is public you should be able to download the archive without authentication. But you might still get a HTML response if you are being redirected. In that case you can pass the option -L, --location to curl:

curl -L https://gitlab.com/dafabe/example/-/jobs/artifacts/master/download?job=build --output filename.zip

You can find out in which scenario you are by inspecting the content of your donwloaded HTML page.

To login with a personal token (see here for help on how to create one, pick api for scope), enter:

curl -L -H "PRIVATE-TOKEN: XXXXXXXX" https://gitlab.com/dafabe/example/-/jobs/artifacts/master/download?job=build --output filename.zip

where XXXXXXXX should be replaced by the token you have generated.