跳转至

下载工作流运行的job日志

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

下载工作流运行中指定 job 的日志文件。

访问令牌支持说明

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

是否允许匿名访问

此接口不允许匿名访问

请求参数

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

响应参数

成功时直接返回 job 的日志文件内容(文件流)。参考文档未定义结构化响应字段,Schema 为 {},实际内容为日志文本。

失败响应

401 未认证

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

404 未找到

{
  "error": "not_found",
  "message": "工作流运行、任务或仓库不存在"
}

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

HTTP 响应状态码

状态码 说明
200 成功(OK),返回日志文件内容
401 需要认证(缺少或无效的访问令牌)
404 仓库、工作流运行或任务不存在

请求示例

参数说明

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

cURL

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

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const owner = "<owner>";
const repo = "<repo>";
const runId = "<run_id>";
const jobId = "<job_id>";
const token = "<token>";

const response = await fetch(
  `https://api.atomgit.com/api/v8/repos/${owner}/${repo}/actions/runs/${runId}/jobs/${jobId}/download_log?access_token=${token}`,
  { headers: { "Accept": "application/json" } }
);

if (!response.ok) {
  throw new Error(`请求失败: ${response.status}`);
}

const log = await response.text();
console.log(log);

Python

import requests

owner = "<owner>"
repo = "<repo>"
run_id = "<run_id>"
job_id = "<job_id>"
token = "<token>"

url = f"https://api.atomgit.com/api/v8/repos/{owner}/{repo}/actions/runs/{run_id}/jobs/{job_id}/download_log"

resp = requests.get(
    url,
    params={"access_token": token},
    headers={"Accept": "application/json"},
    timeout=10,
)
resp.raise_for_status()

print(resp.text)

响应示例

状态码: 200

2026-10-14 07:00:01.234  INFO  1 --- [main] c.g.actions.JobRunner : Starting job <job_id>
2026-10-14 07:00:02.345  INFO  1 --- [main] c.g.actions.JobRunner : Checkout repository <owner>/<repo>
2026-10-14 07:00:03.456  INFO  1 --- [main] c.g.actions.JobRunner : Build started

实际返回内容为 job 运行时的日志文本,具体取决于运行过程。

错误码

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

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