跳转至

获取流水线的运行详情

GET /api/v8/repos/{owner}/{repo}/actions/runs/{run_id}

获取指定仓库中某条流水线运行的详情信息,包括运行状态、触发事件、执行人、阶段与任务明细。

访问令牌支持说明

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

是否允许匿名访问

此接口允许匿名访问

请求参数

参数名 位置 类型 必填 说明
owner path string 是 仓库所属空间地址(组织或个人的地址 path)
repo path string 是 仓库路径(path)
run_id path string 是 流水线运行 id

响应参数

字段 类型 必返 可为空 说明
workflow_run_id string 是 — 流水线运行 id
workflow_id string 是 — 流水线 id
workflow_name string 是 — 流水线名称
file_path string 是 — 文件路径
title string 是 — 标题
status string 是 — 运行状态;枚举:COMPLETED(已完成)、RUNNING(运行中)、FAILED(失败)、CANCELED(取消)、IGNORED(忽略)、PAUSED(暂停)、SUSPEND(挂起)
event string 是 — 触发事件类型;枚举:MR(mr 事件)、Push(推送事件)、Manual(手动触发)
run_number integer 是 — 运行编号
head_branch string 是 — 头部分支
head_sha string 是 — 头提交 SHA
pull_request_id string 否 是 拉取请求 id
actor object 是 否 触发人(执行者)
start_time integer 是 — 开始时间戳
end_time integer 是 — 结束时间戳
pause_time integer 是 — 暂停时长
attempt integer 否 是 当前 workflow run 的尝试序号;底座未指定时默认为 1
exist_in_default_branch boolean 是 — 是否在默认分支
stages array 是 是 阶段信息

actor 对象

字段 类型 必返 可为空 说明
actor.id string 是 — 用户 id
actor.object_id string 是 — 对象 id
actor.login string 是 — 登录名
actor.name string 是 — 用户名

stages 对象

字段 类型 必返 可为空 说明
stages[].id string 是 — 阶段 id
stages[].category string 是 — 分类
stages[].name string 是 — 名称
stages[].identifier string 是 — 标识符
stages[].run_always boolean 是 — 是否始终运行
stages[].fail_fast boolean 是 — 是否快速失败
stages[].parallel null 是 是 并行配置
stages[].is_select boolean 是 — 是否被选中
stages[].sequence integer 是 — 序号
stages[].depends_on string[] 是 — 依赖项
stages[].condition null 是 是 运行条件
stages[].status string 是 — 状态
stages[].start_time integer 是 — 开始时间戳
stages[].end_time integer 是 — 结束时间戳
stages[].pause_time integer 是 — 暂停时长
stages[].pre object[] 是 是 前置任务
stages[].post string[] 是 — 后置任务
stages[].jobs object[] 是 是 流水线运行任务信息

stages.pre 对象

字段 类型 必返 可为空 说明
stages.pre[].runtime_attribution null 是 是 运行时归属
stages.pre[].multi_step_editable integer 是 — 是否支持多步编辑
stages.pre[].official_task_version null 是 是 官方任务版本
stages.pre[].icon_url null 是 是 图标 URL
stages.pre[].name null 是 是 名称
stages.pre[].task string 是 — 任务
stages.pre[].business_type null 是 是 业务类型
stages.pre[].inputs string[] 是 — 输入
stages.pre[].env null 是 是 环境变量
stages.pre[].sequence null 是 是 序号
stages.pre[].identifier null 是 是 标识符
stages.pre[].endpoint_ids null 是 是 端点 id
stages.pre[].id string 是 — 任务 id
stages.pre[].job_run_id string 是 — 任务运行 id
stages.pre[].last_dispatch_id string 是 — 最近一次调度 id
stages.pre[].status string 是 — 状态
stages.pre[].message null 是 是 消息
stages.pre[].start_time integer 是 — 开始时间戳
stages.pre[].end_time integer 是 — 结束时间戳
stages.pre[].daily_build_number null 是 是 每日构建编号
stages.pre[].timeout-minutes null 是 是 超时时间(分钟)
stages.pre[].continue-on-error null 是 是 是否允许失败继续

stages.jobs 对象

字段 类型 必返 可为空 说明
stages.jobs[].id string 是 — 任务 id
stages.jobs[].category null 是 是 分类
stages.jobs[].sequence integer 是 — 序号
stages.jobs[].async null 是 是 是否异步
stages.jobs[].name string 是 — 任务名称
stages.jobs[].identifier string 是 — 标识符
stages.jobs[].depends_on string[] 是 — 依赖项
stages.jobs[].condition string 是 — 运行条件
stages.jobs[].resource string 是 — 运行资源
stages.jobs[].is_select boolean 是 — 是否被选中
stages.jobs[].timeout null 是 是 超时时间
stages.jobs[].last_dispatch_id string 是 — 最近一次调度 id
stages.jobs[].execute_cost_time integer 是 — 执行耗时(秒)
stages.jobs[].status string 是 — 状态
stages.jobs[].message null 是 是 消息
stages.jobs[].start_time integer 是 — 开始时间戳
stages.jobs[].end_time integer 是 — 结束时间戳
stages.jobs[].exec_id string 是 — 执行实例 id
stages.jobs[].steps object[] 是 是 步骤信息
stages.jobs[].job_type string 是 — 任务类型
stages.jobs[].max_parallel null 是 是 最大并行数
stages.jobs[].fail_fast null 是 是 是否快速失败
stages.jobs[].from null 是 是 来源
stages.jobs[].with null 是 是 with 配置
stages.jobs[].secrets null 是 是 机密配置
stages.jobs[].outputs_define null 是 是 输出定义
stages.jobs[].concurrency null 是 是 并发配置
stages.jobs[].timeout_minutes null 是 是 超时时间(分钟)
stages.jobs[].continue_on_error null 是 是 是否允许失败继续

stages.jobs.steps 对象

字段 类型 必返 可为空 说明
stages.jobs.steps[].runtime_attribution null 是 是 运行时归属
stages.jobs.steps[].multi_step_editable integer 是 — 是否支持多步编辑
stages.jobs.steps[].official_task_version null 是 是 官方任务版本
stages.jobs.steps[].icon_url null 是 是 图标 URL
stages.jobs.steps[].name string 是 — 步骤名称
stages.jobs.steps[].task string 是 — 任务
stages.jobs.steps[].business_type null 是 是 业务类型
stages.jobs.steps[].inputs object[] 是 — 输入(键值对)
stages.jobs.steps[].env string[] 是 — 环境变量
stages.jobs.steps[].sequence integer 是 — 序号
stages.jobs.steps[].identifier string 是 — 标识符
stages.jobs.steps[].endpoint_ids null 是 是 端点 id
stages.jobs.steps[].id string 是 — 步骤 id
stages.jobs.steps[].job_run_id string 是 — 任务运行 id
stages.jobs.steps[].last_dispatch_id string 是 — 最近一次调度 id
stages.jobs.steps[].status string 是 — 状态
stages.jobs.steps[].message null 是 是 消息
stages.jobs.steps[].start_time integer 是 — 开始时间戳
stages.jobs.steps[].end_time integer 是 — 结束时间戳
stages.jobs.steps[].daily_build_number null 是 是 每日构建编号
stages.jobs.steps[].timeout-minutes null 是 是 超时时间(分钟)
stages.jobs.steps[].continue-on-error null 是 是 是否允许失败继续

stages.jobs.steps.inputs 对象

字段 类型 必返 可为空 说明
stages.jobs.steps.inputs[].key string 是 — 键
stages.jobs.steps.inputs[].value string 是 — 值

失败响应

该接口在参数缺失或格式错误、认证失败、资源不存在时会返回对应的错误响应。

400 参数错误

{
  "error": "invalid_request",
  "message": "参数 owner 不能为空",
  "field": "owner"
}

401 未认证

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

404 资源不存在

{
  "error": "not_found",
  "message": "流水线运行记录不存在"
}

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

HTTP 响应状态码

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

请求示例

参数说明

示例必须与本文档其余部分自洽,照抄即可调用成功:

  1. 该接口允许匿名访问,示例中不带认证参数即可调用成功;如需认证,可携带 access_token 查询参数。
  2. 三个路径参数均为必填项,必须全部出现在请求中。
  3. 占位符统一使用 <...> 形式,替换为真实值后即可调用。

<owner> 替换为仓库所属空间地址(组织或个人的地址 path);<repo> 替换为仓库路径(path);<run_id> 替换为流水线运行 id。

cURL

curl -X GET 'https://api.atomgit.com/api/v8/repos/<owner>/<repo>/actions/runs/<run_id>' \
  -H 'Accept: application/json'

如需携带令牌认证,可追加 access_token 查询参数:

curl -X GET 'https://api.atomgit.com/api/v8/repos/<owner>/<repo>/actions/runs/<run_id>?access_token=<token>' \
  -H 'Accept: application/json'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v8/repos/<owner>/<repo>/actions/runs/<run_id>", {
  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/<run_id>",
    headers={"Accept": "application/json"},
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

响应示例

状态码: 200

{
  "workflow_run_id": "run-2024010101",
  "workflow_id": "wf-1",
  "workflow_name": "CI",
  "file_path": ".gitcode/workflows/ci.yml",
  "title": "CI",
  "status": "COMPLETED",
  "event": "Push",
  "run_number": 3,
  "head_branch": "main",
  "head_sha": "abc123def456",
  "pull_request_id": null,
  "actor": {
    "id": "1",
    "object_id": "obj-1",
    "login": "octocat",
    "name": "octocat"
  },
  "start_time": 1700000000,
  "end_time": 1700003600,
  "pause_time": 0,
  "attempt": 1,
  "exist_in_default_branch": true,
  "stages": [
    {
      "id": "stage-1",
      "category": "parallel",
      "name": "Build",
      "identifier": "build",
      "run_always": true,
      "fail_fast": false,
      "is_select": true,
      "sequence": 1,
      "depends_on": [],
      "status": "COMPLETED",
      "start_time": 1700000000,
      "end_time": 1700003600,
      "pause_time": 0,
      "pre": [
        {
          "multi_step_editable": 1,
          "task": "checkout",
          "inputs": ["main"],
          "id": "pre-1",
          "job_run_id": "jr-1",
          "last_dispatch_id": "ld-1",
          "status": "COMPLETED",
          "start_time": 1700000000,
          "end_time": 1700000100
        }
      ],
      "post": [],
      "jobs": [
        {
          "id": "job-1",
          "sequence": 1,
          "name": "build",
          "identifier": "build",
          "depends_on": [],
          "condition": "success()",
          "resource": "linux",
          "is_select": true,
          "last_dispatch_id": "ld-1",
          "execute_cost_time": 3600,
          "status": "COMPLETED",
          "start_time": 1700000000,
          "end_time": 1700003600,
          "exec_id": "exec-1",
          "steps": [
            {
              "multi_step_editable": 1,
              "name": "Run build",
              "task": "shell",
              "inputs": [
                {
                  "key": "script",
                  "value": "make build"
                }
              ],
              "env": [],
              "sequence": 1,
              "identifier": "run-build",
              "id": "step-1",
              "job_run_id": "jr-1",
              "last_dispatch_id": "ld-1",
              "status": "COMPLETED",
              "start_time": 1700000000,
              "end_time": 1700000300
            }
          ],
          "job_type": "build"
        }
      ]
    }
  ]
}

错误码

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

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