Gitlab-API 探索

2,372 阅读1分钟

背景:暂时因为shell脚本找不到npm 命令陷入停滞,研究API调用方法,这里主要研究跟pipeline相关的

参考文档,gitlabAPI

API调用之前需要一个token,生成方法如下

token生成方法

项目id查询方法

项目id查询方法


#token
可以在参数上加private_token 或者在请求头上加 Private-Token
原文:You can use a personal access token to authenticate with the API by passing it in either the private_token parameter or the Private-Token header.

查询项目下所有pipelines 可以附加的参数有

参数 释义 123
status row 1 col 2
row 2 col 1 row 2 col 2
Attribute Type Required Description
id integer/string yes The ID or URL-encoded path of the project owned by the authenticated user
scope string no The scope of pipelines, one of: running, pending, finished, branches, tags
status string no The status of pipelines, one of: running, pending, success, failed, canceled, skipped
ref string no The ref of pipelines
sha string no The sha or pipelines
yaml_errors boolean no Returns pipelines with invalid configurations
name string no The name of the user who triggered pipelines
username string no The username of the user who triggered pipelines
order_by string no Order pipelines by id, status, ref, or user_id (default: id)
sort string no Sort pipelines in asc or desc order (default: desc)
GET /api/v4/projects/:id/pipelines // 这里的id是指项目的id
https://git-v.megvii-inc.com/api/v4/projects/943/pipelines?private_token=njVo6qWdNrW4kXcTVzz5