已关闭
feat(actions): 支持 获取工作流运行的job详情 API #449
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 view代码(pkg/cmd/actions/job/仅有list,#448 交付)。- 近 25 个 PR 无一
Closes #449(#378/#381 body 命中只是自检里"后续 #449"的提及,非关闭引用)。 - 本 issue 0 评论,无关闭原因记录;labels 仍
status/triage(非status/merged)。
按 AGENTS.md §9:"如果 issue 已关闭但没有 merged PR 或 origin/main 不包含对应代码,必须明确判定为'未完成主干合入'"。故判定 #449 = 未完成主干合入,重开以按全流程交付。
验证记录
- 需求确认: GitCode API v8 提供
GET /api/v8/repos/{owner}/{repo}/actions/runs/{run_id}/jobs/{job_id}(工作流运行 job 详情),OpenAPI 已抓取于本 issue body。响应为单个 job 对象,与 #446/#448 的WorkflowRunJob同构(id/name/identifier/status/sequence/job_type/resource/condition/is_select/depends_on/start_time/end_time/execute_cost_time/exec_id/last_dispatch_id/steps + 可空字段)。 - gc 现状: pkg/cmd/actions/job 下有 list(#448),无 view;api 无 GetActionsJob。
- 结论: 需求有效且未实现,进入开发。
实现计划
- API 层: 复用 WorkflowRunJob;新增
GetActionsJob(client, owner, repo, runID, jobID) → (*WorkflowRunJob, json.RawMessage, error)(RawREST 走 v8runs/{run_id}/jobs/{job_id};返回 typed + raw,raw 供 --json 忠实透传 steps 深层 inputs/env 等,同 #446 view 模式)。 - 命令层:
gc actions job view <run-id> <job-id> -R owner/repo [--json](两位置参数,对应 API 路径 run_id/job_id;cobra.ExactArgs(2));注册到 #448 建的 job 父组。 - 输出: job 元信息 + steps 列表(名称/task/status/时间),时间用 ms 检测格式化(复用 #458 的 ms 检测逻辑)。
- 真实验证: infra-test 404 + wangjing_127/MindIE-SD run #55 真实 job(codecheck/SCA/Antipoison 有真实 job_id,首次验 job 详情成功路径)。


背景
GitCode API 文档 2.0.0 已提供 Actions API。该 Issue 用于跟踪 gitcode-cli 对此接口的支持设计与实现。
API 摘要
GET/api/v8/repos/{owner}/{repo}/actions/runs/{run_id}/jobs/{job_id}get_api_v8_repos_{owner}_{repo}_actions_runs_{run_id}_jobs_{job_id}pipeline-v8falseRequest Parameters
ownerreporun_idjob_idaccess_tokenRequest Body
无。
Responses
200
application/jsonapplication/json schema
{ "type": "object", "properties": { "id": { "type": "string", "description": "任务id" }, "category": { "type": "null" }, "sequence": { "type": "integer" }, "async": { "type": "null" }, "name": { "type": "string", "description": "任务名称" }, "identifier": { "type": "string" }, "depends_on": { "type": "array", "items": { "type": "string" } }, "condition": { "type": "string" }, "resource": { "type": "string" }, "is_select": { "type": "boolean" }, "timeout": { "type": "null" }, "last_dispatch_id": { "type": "string" }, "execute_cost_time": { "type": "integer" }, "status": { "type": "string", "description": "任务状态。COMPLETED(已完成),RUNNING(运行中),FAILED(失败),CANCELED(取消),IGNORED(忽略),PAUSED(暂停),SUSPEND(挂起)" }, "message": { "type": "null" }, "start_time": { "type": "integer" }, "end_time": { "type": "integer" }, "exec_id": { "type": "string" }, "steps": { "type": "array", "items": { "type": "object", "properties": { "runtime_attribution": { "type": "null" }, "multi_step_editable": { "type": "integer" }, "official_task_version": { "type": "null" }, "icon_url": { "type": "null" }, "name": { "type": "string" }, "task": { "type": "string" }, "business_type": { "type": "null" }, "inputs": { "type": "array", "items": { "type": "object", "properties": { "key": { "type": "string" }, "value": { "type": "string" } }, "required": [ "key", "value" ] } }, "env": { "type": "array", "items": { "type": "string" } }, "sequence": { "type": "integer" }, "identifier": { "type": "string" }, "endpoint_ids": { "type": "null" }, "id": { "type": "string" }, "job_run_id": { "type": "string" }, "last_dispatch_id": { "type": "string" }, "status": { "type": "string" }, "message": { "type": "null" }, "start_time": { "type": "integer" }, "end_time": { "type": "integer" }, "daily_build_number": { "type": "null" }, "timeout-minutes": { "type": "null" }, "continue-on-error": { "type": "null" } }, "required": [ "runtime_attribution", "multi_step_editable", "official_task_version", "icon_url", "name", "task", "business_type", "inputs", "env", "sequence", "identifier", "endpoint_ids", "id", "job_run_id", "last_dispatch_id", "status", "message", "start_time", "end_time", "daily_build_number", "timeout-minutes", "continue-on-error" ] } }, "job_type": { "type": "string" }, "max_parallel": { "type": "null" }, "fail_fast": { "type": "null" }, "from": { "type": "null" }, "with": { "type": "null" }, "secrets": { "type": "null" }, "outputs_define": { "type": "null" }, "concurrency": { "type": "null" }, "timeout_minutes": { "type": "null" }, "continue_on_error": { "type": "null" } }, "required": [ "id", "category", "sequence", "async", "name", "identifier", "depends_on", "condition", "resource", "is_select", "timeout", "last_dispatch_id", "execute_cost_time", "status", "message", "start_time", "end_time", "exec_id", "steps", "job_type", "max_parallel", "fail_fast", "from", "with", "secrets", "outputs_define", "concurrency", "timeout_minutes", "continue_on_error" ] }原始 OpenAPI Operation
{ "deprecated": false, "description": "", "operationId": "get_api_v8_repos_{owner}_{repo}_actions_runs_{run_id}_jobs_{job_id}", "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": false, "example": "", "schema": { "type": "string" } } ], "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string", "description": "任务id" }, "category": { "type": "null" }, "sequence": { "type": "integer" }, "async": { "type": "null" }, "name": { "type": "string", "description": "任务名称" }, "identifier": { "type": "string" }, "depends_on": { "type": "array", "items": { "type": "string" } }, "condition": { "type": "string" }, "resource": { "type": "string" }, "is_select": { "type": "boolean" }, "timeout": { "type": "null" }, "last_dispatch_id": { "type": "string" }, "execute_cost_time": { "type": "integer" }, "status": { "type": "string", "description": "任务状态。COMPLETED(已完成),RUNNING(运行中),FAILED(失败),CANCELED(取消),IGNORED(忽略),PAUSED(暂停),SUSPEND(挂起)" }, "message": { "type": "null" }, "start_time": { "type": "integer" }, "end_time": { "type": "integer" }, "exec_id": { "type": "string" }, "steps": { "type": "array", "items": { "type": "object", "properties": { "runtime_attribution": { "type": "null" }, "multi_step_editable": { "type": "integer" }, "official_task_version": { "type": "null" }, "icon_url": { "type": "null" }, "name": { "type": "string" }, "task": { "type": "string" }, "business_type": { "type": "null" }, "inputs": { "type": "array", "items": { "type": "object", "properties": { "key": { "type": "string" }, "value": { "type": "string" } }, "required": [ "key", "value" ] } }, "env": { "type": "array", "items": { "type": "string" } }, "sequence": { "type": "integer" }, "identifier": { "type": "string" }, "endpoint_ids": { "type": "null" }, "id": { "type": "string" }, "job_run_id": { "type": "string" }, "last_dispatch_id": { "type": "string" }, "status": { "type": "string" }, "message": { "type": "null" }, "start_time": { "type": "integer" }, "end_time": { "type": "integer" }, "daily_build_number": { "type": "null" }, "timeout-minutes": { "type": "null" }, "continue-on-error": { "type": "null" } }, "required": [ "runtime_attribution", "multi_step_editable", "official_task_version", "icon_url", "name", "task", "business_type", "inputs", "env", "sequence", "identifier", "endpoint_ids", "id", "job_run_id", "last_dispatch_id", "status", "message", "start_time", "end_time", "daily_build_number", "timeout-minutes", "continue-on-error" ] } }, "job_type": { "type": "string" }, "max_parallel": { "type": "null" }, "fail_fast": { "type": "null" }, "from": { "type": "null" }, "with": { "type": "null" }, "secrets": { "type": "null" }, "outputs_define": { "type": "null" }, "concurrency": { "type": "null" }, "timeout_minutes": { "type": "null" }, "continue_on_error": { "type": "null" } }, "required": [ "id", "category", "sequence", "async", "name", "identifier", "depends_on", "condition", "resource", "is_select", "timeout", "last_dispatch_id", "execute_cost_time", "status", "message", "start_time", "end_time", "exec_id", "steps", "job_type", "max_parallel", "fail_fast", "from", "with", "secrets", "outputs_define", "concurrency", "timeout_minutes", "continue_on_error" ] } } }, "headers": {} } }, "security": [], "method": "get", "path": "/api/v8/repos/{owner}/{repo}/actions/runs/{run_id}/jobs/{job_id}", "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" ], "host": [ "{{baseUrl}}" ], "query": [ { "disabled": false, "description": { "content": "用户授权码", "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": "application/json" } ], "method": "GET" } }初步验收建议
infra-test/*仓库。access_token仅作为 API 参数记录,CLI 优先复用现有认证机制。