跳转至

查询Runner资源的Job执行历史

GET /api/v8/orgs/{org}/actions/runner-resources/job-history

用户调用此接口,查询指定组织的 Runner 资源的 Job 执行历史。

访问令牌支持说明

  • AtomGit 用户访问令牌(AtomGit user access tokens)

是否允许匿名访问

此接口不允许匿名访问

请求参数

参数名 位置 类型 必填 说明
org path string 是 组织路径
access_token query string 是 用户授权码
page query integer 否 当前页码
per_page query integer 否 每页的项目数
start_time_begin query string 否 开始时间过滤起始,格式:yyyy-MM-dd HH:mm:ss
start_time_end query string 否 开始时间过滤结束,格式:yyyy-MM-dd HH:mm:ss

响应参数

字段 类型 必返 可为空 说明
page_num integer 是 — 当前页码
page_size integer 是 — 每页条数
total integer 是 — 总记录数
page_count integer 是 — 总页数
content array 是 — Job 执行历史列表

content 对象

字段 类型 必返 可为空 说明
content.state string 是 — 执行状态
content.duration integer 是 — 执行时长
content.org_namespace_id string 是 — 组织命名空间 ID
content.repo_namespace_id string 是 — 仓库命名空间 ID
content.job_run_id string 是 — Job 运行 ID
content.job_id string 是 — Job ID
content.job_external_id string 是 — Job 外部 ID
content.job_name string 是 — Job 名称
content.pipeline_external_id string 是 — 流水线外部 ID
content.pipeline_origin_id string 是 — 流水线来源 ID
content.pipeline_run_id string 是 — 流水线运行 ID
content.pipeline_name string 是 — 流水线名称
content.runs_on string 是 — 运行环境
content.start_time string 是 — 开始时间
content.complete_time string 是 — 完成时间

失败响应

只有成功响应是不够的:调用方需要知道失败长什么样才能写错误处理。

400 参数错误

{
  "error": "invalid_request",
  "message": "参数 page 不合法",
  "field": "page"
}

401 未认证

{
  "error": "unauthorized",
  "message": "缺少或无效的访问令牌"
}

错误字段名以后端实际返回为准。

HTTP 响应状态码

状态码 说明
200 成功(OK)
400 参数错误(Bad Request)
401 需要认证(Requires authentication)
403 禁止访问(Forbidden)
429 请求过于频繁(Too many requests)
500 系统内部错误(Internal server error)

请求示例

参数说明

示例中的占位符按需替换:

<org> 替换为组织路径;<token> 替换为你的 AtomGit 用户访问令牌。

cURL

curl -X GET 'https://api.atomgit.com/api/v8/orgs/<org>/actions/runner-resources/job-history?access_token=<token>&page=1&per_page=10' \
  -H 'Accept: application/json'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch(
  "https://api.atomgit.com/api/v8/orgs/<org>/actions/runner-resources/job-history?access_token=<token>&page=1&per_page=10",
  {
    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/orgs/<org>/actions/runner-resources/job-history",
    params={
        "access_token": "<token>",
        "page": 1,
        "per_page": 10,
    },
    headers={
        "Accept": "application/json",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

响应示例

状态码: 200

{
  "page_num": 1,
  "page_size": 10,
  "total": 1,
  "page_count": 1,
  "content": [
    {
      "state": "completed",
      "duration": 120,
      "org_namespace_id": "gitcode",
      "repo_namespace_id": "my-repo",
      "job_run_id": "123456",
      "job_id": "job-1",
      "job_external_id": "JOB-001",
      "job_name": "build",
      "pipeline_external_id": "PIPE-001",
      "pipeline_origin_id": "origin-1",
      "pipeline_run_id": "run-1",
      "pipeline_name": "CI",
      "runs_on": "ubuntu-latest",
      "start_time": "2024-01-01 10:00:00",
      "complete_time": "2024-01-01 10:02:00"
    }
  ]
}

错误码

错误码 说明
401 未认证或凭证无效(缺少/无效的访问凭证)
400 参数错误或请求无法解析
404 请求路径不存在
405 请求方法不支持
429 请求过于频繁,触发限流
500 系统内部错误

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc