已关闭
feat(actions): 支持 下载工作流运行的job日志 API #450
aflyingto创建于 7月9日关闭于 7月10日
aflyingto
7月10日 评论:
7月10日 评论:
重开记录(按 AGENTS §9 判定"未完成主干合入")
本 issue 此前为 closed 状态,但核验发现:
verify-remote-facts失败:closed issue 无 merged PR 可核验。origin/main不含gc actions job log代码(pkg/cmd/actions/job/仅有 list/view,无 log;api 无 job-log 查询函数)。- 近 PR 无一
Closes #450(#378/#381 body 命中只是自检里"后续 #450"的提及)。 - 本 issue 0 评论,无关闭原因;labels 仍
status/triage(非status/merged)。
按 AGENTS.md §9 判定 #450 = 未完成主干合入(与此前 #449 同源,疑似批量关闭 M1 时误关未交付项)。重开以按全流程交付。
验证记录
- 需求确认: GitCode API v8 提供
GET /api/v8/repos/{owner}/{repo}/actions/runs/{run_id}/jobs/{job_id}/download_log(下载 job 日志),OpenAPI 已抓取于本 issue body。响应 Content-Type*/*、schema 空 → 原始日志内容(非结构化 JSON)。 - gc 现状: pkg/cmd/actions/job 下有 list/view,无 log;api 无 job-log 函数。
- 结论: 需求有效且未实现,进入开发。
实现计划
- API 层:
GetActionsJobLog(client, owner, repo, runID, jobID) ([]byte, error)——RawREST GET download_log,返回原始响应体(日志字节,非 JSON 解析)。 - 命令层:
gc actions job log <run-id> <job-id> -R owner/repo [--output/-o FILE]——默认输出日志到 stdout(原始字节,便于| grep/重定向);--output写文件。两位置参数(run-id/job-id),同 #449 job view。无--json(日志非结构化)。 - 认证: 复用 Bearer header(按 security 规范不通过 access_token query 暴露 token)。API 文档标 access_token 为 required,但 GitCode 接受 Bearer;真实验证确认。
- 真实验证: infra-test 404 + wangjing_127/MindIE-SD 真实 job(codecheck 有 job_id,可下载日志)。


背景
GitCode API 文档 2.0.0 已提供 Actions API。该 Issue 用于跟踪 gitcode-cli 对此接口的支持设计与实现。
API 摘要
GET/api/v8/repos/{owner}/{repo}/actions/runs/{run_id}/jobs/{job_id}/download_logget_api_v8_repos_{owner}_{repo}_actions_runs_{run_id}_jobs_{job_id}_download_logpipeline-v8falseRequest Parameters
ownerreporun_idjob_idaccess_tokenRequest Body
无。
Responses
200
*/*/ schema
{ "type": "object", "properties": {} }原始 OpenAPI Operation
{ "deprecated": false, "description": "", "operationId": "get_api_v8_repos_{owner}_{repo}_actions_runs_{run_id}_jobs_{job_id}_download_log", "tags": [ "pipeline-v8" ], "parameters": [ { "name": "owner", "in": "path", "description": "仓库所属空间地址(组织或个人的地址path)", "required": true, "schema": { "type": "string" } }, { "name": "repo", "in": "path", "description": "仓库路径(path)", "required": true, "schema": { "type": "string" } }, { "name": "run_id", "in": "path", "description": "流水线运行id", "required": true, "schema": { "type": "string" } }, { "name": "job_id", "in": "path", "description": "任务id", "required": true, "schema": { "type": "string" } }, { "name": "access_token", "in": "query", "description": "用户授权码", "required": true, "example": "", "schema": { "type": "string" } } ], "responses": { "200": { "description": "", "content": { "*/*": { "schema": { "type": "object", "properties": {} } } }, "headers": {} } }, "security": [], "method": "get", "path": "/api/v8/repos/{owner}/{repo}/actions/runs/{run_id}/jobs/{job_id}/download_log", "servers": [ { "url": "https://api.gitcode.com", "description": "正式环境" } ], "securitySchemes": {}, "info": { "title": "GicodeOpenAPI", "description": "", "version": "1.0.0" }, "postman": { "name": "下载工作流运行的job日志", "description": { "content": "", "type": "text/plain" }, "url": { "path": [ "api", "v8", "repos", ":owner", ":repo", "actions", "runs", ":run_id", "jobs", ":job_id", "download_log" ], "host": [ "{{baseUrl}}" ], "query": [ { "disabled": false, "description": { "content": "(Required) 用户授权码", "type": "text/plain" }, "key": "access_token", "value": "" } ], "variable": [ { "disabled": false, "description": { "content": "(Required) 仓库所属空间地址(组织或个人的地址path)", "type": "text/plain" }, "type": "any", "value": "", "key": "owner" }, { "disabled": false, "description": { "content": "(Required) 仓库路径(path)", "type": "text/plain" }, "type": "any", "value": "", "key": "repo" }, { "disabled": false, "description": { "content": "(Required) 流水线运行id", "type": "text/plain" }, "type": "any", "value": "", "key": "run_id" }, { "disabled": false, "description": { "content": "(Required) 任务id", "type": "text/plain" }, "type": "any", "value": "", "key": "job_id" } ] }, "header": [ { "key": "Accept", "value": "*/*" } ], "method": "GET" } }初步验收建议
infra-test/*仓库。access_token仅作为 API 参数记录,CLI 优先复用现有认证机制。