跳转至

获取工作流运行的job详情

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

用户调用此接口,获取工作流运行的 job 详情。

访问令牌支持说明

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

是否允许匿名访问

此接口允许匿名访问

请求参数

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

响应参数

字段 类型 必返 可为空 说明
id string 是 否 任务 id
category null 是 是 分类(以实际返回为准)
sequence integer 是 否 序号
async null 是 是 是否异步(以实际返回为准)
name string 是 否 任务名称
identifier string 是 否 任务标识
depends_on string[] 是 否 依赖的任务标识列表
condition string 是 否 运行条件
resource string 是 否 运行资源
is_select boolean 是 否 是否可选
timeout null 是 是 超时时间(以实际返回为准)
last_dispatch_id string 是 否 最近一次派发 id
execute_cost_time integer 是 否 执行耗时
status string 是 否 任务状态。枚举:COMPLETED(已完成)、RUNNING(运行中)、FAILED(失败)、CANCELED(取消)、IGNORED(忽略)、PAUSED(暂停)、SUSPEND(挂起)
message null 是 是 提示信息(以实际返回为准)
start_time integer 是 否 开始时间
end_time integer 是 否 结束时间
exec_id string 是 否 执行 id
steps object[] 是 否 步骤列表
job_type string 是 否 任务类型
max_parallel null 是 是 最大并行数(以实际返回为准)
fail_fast null 是 是 是否快速失败(以实际返回为准)
from null 是 是 来源(以实际返回为准)
with null 是 是 参数(以实际返回为准)
secrets null 是 是 密钥(以实际返回为准)
outputs_define null 是 是 输出定义(以实际返回为准)
concurrency null 是 是 并发配置(以实际返回为准)
timeout_minutes null 是 是 超时分钟数(以实际返回为准)
continue_on_error null 是 是 出错时是否继续(以实际返回为准)

steps 数组元素

字段 类型 必返 可为空 说明
runtime_attribution null 是 是 运行时归属(以实际返回为准)
multi_step_editable integer 是 否 是否支持多步骤编辑
official_task_version null 是 是 官方任务版本(以实际返回为准)
icon_url null 是 是 图标地址(以实际返回为准)
name string 是 否 步骤名称
task string 是 否 任务标识
business_type null 是 是 业务类型(以实际返回为准)
inputs object[] 是 否 输入参数列表
env string[] 是 否 环境变量列表
sequence integer 是 否 序号
identifier string 是 否 步骤标识
endpoint_ids null 是 是 端点 id 列表(以实际返回为准)
id string 是 否 步骤 id
job_run_id string 是 否 任务运行 id
last_dispatch_id string 是 否 最近一次派发 id
status string 是 否 步骤状态
message null 是 是 提示信息(以实际返回为准)
start_time integer 是 否 开始时间
end_time integer 是 否 结束时间
daily_build_number null 是 是 每日构建号(以实际返回为准)
timeout-minutes null 是 是 超时分钟数(以实际返回为准)
continue-on-error null 是 是 出错时是否继续(以实际返回为准)

steps.inputs 数组元素

字段 类型 必返 可为空 说明
key string 是 否 输入项 key
value string 是 否 输入项 value

失败响应

该接口无业务失败响应。

HTTP 响应状态码

状态码 说明
200 成功(OK)
401 需要认证(Requires authentication)
403 禁止访问(Forbidden)
404 未找到(Not found)

请求示例

参数说明

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

该接口允许匿名访问,请求时可不携带认证信息;如需访问受保护的仓库,可额外携带 AtomGit 用户访问令牌。

cURL

curl -X GET 'https://api.atomgit.com/api/v8/repos/<owner>/<repo>/actions/runs/<run_id>/jobs/<job_id>' -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>/jobs/<job_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>/jobs/<job_id>",
    headers={
        "Accept": "application/json",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

响应示例

状态码: 200

{
  "id": "string",
  "sequence": 0,
  "name": "string",
  "identifier": "string",
  "depends_on": [
    "string"
  ],
  "condition": "string",
  "resource": "string",
  "is_select": true,
  "last_dispatch_id": "string",
  "execute_cost_time": 0,
  "status": "string",
  "start_time": 0,
  "end_time": 0,
  "exec_id": "string",
  "steps": [
    {
      "multi_step_editable": 0,
      "name": "string",
      "task": "string",
      "inputs": [
        {
          "key": "string",
          "value": "string"
        }
      ],
      "env": [
        "string"
      ],
      "sequence": 0,
      "identifier": "string",
      "id": "string",
      "job_run_id": "string",
      "last_dispatch_id": "string",
      "status": "string",
      "start_time": 0,
      "end_time": 0
    }
  ],
  "job_type": "string"
}

错误码

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

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