获取仓库所有的流水线的运行记录¶
GET /api/v8/repos/{owner}/{repo}/actions/runs
用户调用此接口,获取指定仓库下所有流水线的运行记录。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(组织或个人的地址 path) |
repo |
path | string | 是 | 仓库路径(path) |
event |
query | string | 否 | 触发事件类型,枚举:MR(mr 事件)、Push(推送事件)、Manual(手动触发) |
status |
query | string | 否 | 运行状态,枚举:COMPLETED(已完成)、RUNNING(运行中)、FAILED(失败)、CANCELED(取消)、IGNORED(忽略)、PAUSED(暂停)、SUSPEND(挂起) |
branch |
query | string | 否 | 分支过滤 |
executor |
query | string | 否 | 触发人用户名 |
pull_request_id |
query | string | 否 | PR 的编号 |
workflow_id |
query | string | 否 | 流水线 id |
workflow_name |
query | string | 否 | 流水线名称 |
per_page |
query | string | 否 | 每页的数量,最大为 100,默认 20 |
page |
query | string | 否 | 当前的页码,默认为 1 |
startTime |
query | number | 否 | 开始时间,格式为时间戳 |
endTime |
query | number | 否 | 结束时间,格式为时间戳 |
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
total_count |
integer | 是 | 否 | 总数量 |
workflow_runs |
object[] | 是 | 否 | 流水线运行记录列表 |
workflow_runs 数组元素对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
workflow_runs.workflow_run_id |
string | 是 | 否 | 流水线运行 id |
workflow_runs.workflow_id |
string | 是 | 否 | 流水线 id |
workflow_runs.workflow_name |
string | 是 | 否 | 流水线名称 |
workflow_runs.file_path |
string | 是 | 否 | 工作流文件路径 |
workflow_runs.title |
string | 是 | 否 | 标题 |
workflow_runs.status |
string | 是 | 否 | 运行状态,枚举:COMPLETED(已完成)、RUNNING(运行中)、FAILED(失败)、CANCELED(取消)、IGNORED(忽略)、PAUSED(暂停)、SUSPEND(挂起) |
workflow_runs.event |
string | 是 | 否 | 触发事件类型,枚举:MR(mr 事件)、Push(推送事件)、Manual(手动触发) |
workflow_runs.run_number |
integer | 是 | 否 | 运行序号 |
workflow_runs.head_branch |
string | 是 | 否 | 触发分支 |
workflow_runs.head_sha |
string | 是 | 否 | 触发提交的 SHA |
workflow_runs.actor |
object | 是 | 否 | 触发人 |
workflow_runs.start_time |
integer | 是 | 否 | 开始时间戳 |
workflow_runs.end_time |
integer | 是 | 否 | 结束时间戳 |
workflow_runs.pause_time |
integer | 是 | 否 | 暂停时间 |
workflow_runs.actor 对象¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
workflow_runs.actor.id |
string | 是 | 否 | 触发人 ID |
workflow_runs.actor.object_id |
string | 是 | 否 | 触发人对象 ID |
workflow_runs.actor.login |
string | 是 | 否 | 触发人登录名 |
workflow_runs.actor.name |
string | 是 | 否 | 触发人显示名称 |
失败响应¶
错误字段名以后端实际返回为准。
400 参数错误
401 未认证
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
304 |
未修改(Not modified) |
400 |
参数错误(Bad request) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
404 |
资源不存在(Not found) |
429 |
请求过于频繁,触发限流(Rate limited) |
500 |
系统内部错误(Internal server error) |
请求示例¶
参数说明¶
<owner>替换为仓库所属空间地址(组织或个人的地址 path);<repo>替换为仓库路径(path)。该接口允许匿名访问,示例未携带令牌;如需鉴权,可携带 AtomGit 用户访问令牌。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v8/repos/<owner>/<repo>/actions/runs?event=Push&status=COMPLETED&page=1&per_page=20' \
-H 'Accept: application/json'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v8/repos/<owner>/<repo>/actions/runs?event=Push&status=COMPLETED&page=1&per_page=20", {
headers: {
"Accept": "application/json",
},
});
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.get(
"https://api.atomgit.com/api/v8/repos/<owner>/<repo>/actions/runs",
params={
"event": "Push",
"status": "COMPLETED",
"page": 1,
"per_page": 20,
},
headers={
"Accept": "application/json",
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
{
"total_count": 1,
"workflow_runs": [
{
"workflow_run_id": "1001",
"workflow_id": "123456",
"workflow_name": "build",
"file_path": ".atomgit/workflows/build.yml",
"title": "build #1",
"status": "COMPLETED",
"event": "Push",
"run_number": 1,
"head_branch": "main",
"head_sha": "0f1b3e2e2f0aa304caa02aea6e63557c283f91f0",
"actor": {
"id": "10001",
"object_id": "20001",
"login": "octocat",
"name": "Octo Cat"
},
"start_time": 1697529600,
"end_time": 1697529660,
"pause_time": 0
}
]
}
错误码¶
| 错误码 | 说明 |
|---|---|
400 |
参数错误或请求无法解析 |
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
403 |
禁止访问(Forbidden) |
404 |
请求路径不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc