cnb-rs build stage
cnb-rs build stage <sn> <pipeline_id> <stage_id>查看指定构建的 Stage 详情,包括状态、耗时和日志内容。
选项
<sn>:构建号(必填)<pipeline_id>:流水线 ID(必填)<stage_id>:Stage 标识(必填),接受 3 种形式:stage-N(CNB 内部 ID,N从 0 开始,对应.cnb.yml中第 N 个用户 stage)- 系统 stage 名:
prepare/beforeEnd/end/debugDetection - stage 名字(如
hello)——自动通过build status解析成stage-N,多一次 API 调用
继承的全局选项:
--repo <REPO>: 指定仓库路径(格式:group/repo)--json: 以 JSON 格式输出--domain <DOMAIN>: 指定目标域名(默认:cnb.cool)
Stage ID 解析规则
build status <sn> 表中看到的是 stage 名字,但 CNB 后端 API 要的是 stage-N ID 格式。 stage 命令会按下面顺序解析你传的 <stage_id>:
stage-N检测:以stage-开头且后跟数字 → 直接透传,无额外 API 开销- 系统 stage 名 检测:是
prepare/beforeEnd/end/debugDetection之一 → 直接透传 - stage 名字 解析:调
get_build_status拿 stages 列表,跳过系统 stage,按 0 索引找到 name 匹配那条 → 映射为stage-N - 找不到 → 错误退出并列出可用 stage 名 + ID + 系统 stage
示例
bash
# 1. 用 stage 名字(推荐,与 build status 看到的名字一致)
$ cnb-rs build stage cnb-h8o-1josdfrpk cnb-h8o-1josdfrpk-001 hello
Stage: hello
状态: success
耗时: 0s
日志:
$ echo "cnb-rs dogfood: api_trigger started"
cnb-rs dogfood: api_trigger started
...
# 2. 用 CNB 内部 ID stage-N
$ cnb-rs build stage cnb-h8o-1josdfrpk cnb-h8o-1josdfrpk-001 stage-0
# 等价于上面用 hello、少一次 status API 调用
# 3. 系统 stage(CNB 平台自动跑的准备 / 收尾阶段)
$ cnb-rs build stage cnb-h8o-1josdfrpk cnb-h8o-1josdfrpk-001 prepare
Stage: Prepare...
状态: success
耗时: 5s
# 4. 误传不存在的名字 → friendly bail
$ cnb-rs build stage cnb-h8o-1josdfrpk cnb-h8o-1josdfrpk-001 bogus
错误: 找不到 stage `bogus`。可用:
hello (stage-0)
short-sleep (stage-1)
bye (stage-2)
或用系统 stage:prepare / beforeEnd / end / debugDetection