GitLab CI-Build Artifacts命令行下载

GitLab CI-Build Artifacts command line download

GitLab 版本 - 11.8.1 并尝试在 Ubuntu -14.04-LTS 系统的终端上下载 CI-Build artifacts zip 文件。

使用下面的命令

curl -XGET --header "PRIVATE-TOKEN:avxa_afdfouqernadfg" -o artifacts.zip https://gitlab.com/api/v4/projects/78/builds/artifacts/master/download?job=ci-build

命令成功完成,但解压缩 artifacts.zip 文件时出现以下错误。

Archive:  artifacts.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of artifacts.zip or
        artifacts.zip.zip, and cannot find artifacts.zip.ZIP, period.

您的 URL 有误。应该是 jobs 而不是 builds:

curl -X GET --header "PRIVATE-TOKEN:avxa_afdfouqernadfg" -o artifacts.zip "https://gitlab.com/api/v4/projects/78/jobs/artifacts/master/download?job=ci-build"

我还建议在您的 curl 调用中添加一个 -v,这样您就会看到一个错误:HTTP/1.1 404 Not Found.

参见:https://docs.gitlab.com/ee/api/jobs.html#download-the-artifacts-archive