gitlab:如何以编程方式下载在CI管道末尾发布的工件 [英] gitlab: how can i programatically download the artifacts issued at end of CI pipeline

查看:73
本文介绍了gitlab:如何以编程方式下载在CI管道末尾发布的工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Gitlab中,我如何以编程方式下载CI管道末尾发布的人工制品.

In Gitlab, how can i programatically download the artefacts issued at end of a CI pipeline.

通过UI轻松下载它,但是如何通过API获取它.换句话说,是否可以通过令牌或类似方式访问它?

It is easy to download it via the UI but how can I get it through API. In other words, is it possible to access it via a token or similar?

推荐答案

可以通过

获取/projects/:id/jobs/:job_id/artifacts

GET /projects/:id/jobs/:job_id/artifacts

示例请求:

  • 使用PRIVATE-TOKEN标头:

  • Using the PRIVATE-TOKEN header:

curl --location --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/1/jobs/8/artifacts"

  • 使用JOB-TOKEN标头(仅在.gitlab-ci.yml内部):

  • Using the JOB-TOKEN header (only inside .gitlab-ci.yml):

    curl --location --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://gitlab.example.com/api/v4/projects/1/jobs/8/artifacts"
    

  • 使用job_token参数(仅在.gitlab-ci.yml内部):

  • Using the job_token parameter (only inside .gitlab-ci.yml):

    curl --location --form "job-token=$CI_JOB_TOKEN" "https://gitlab.example.com/api/v4/projects/1/jobs/8/artifacts"
    

  • 这篇关于gitlab:如何以编程方式下载在CI管道末尾发布的工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆