circleci-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCircleCI day-to-day developer workflow (CLI)
CircleCI 开发者日常工作流(CLI)
The everyday loop: change config → commit/push → watch the run → read failures → rerun.
Almost every command infers the project from the current git remote and the branch from
your checked-out branch, so from inside a repo you rarely pass /.
--project--branchEvery data-returning command takes , and filters it without a
separate ; human output is markdown. Without a terminal the CLI skips the pager, drops
color, and fails fast naming the missing flag instead of prompting (for example
), so there is nothing to set up defensively.
--json--jq '<expr>'jq--value is required in non-interactive mode.日常循环:修改 config → commit/push → 观察 run → 查看失败 → rerun。
几乎每个命令都会根据当前 git remote 推断 project,并根据当前 checkout 的分支推断 branch,因此进入 repo 后,通常很少需要传入 /。
--project--branch每个返回数据的命令都接受 ,而 可直接过滤结果,无需另行使用 ;人类可读输出为 markdown。没有终端时,CLI 会跳过 pager、去除颜色,并在发现缺少 flag 时立即失败并指出具体 flag,而不是进行提示(例如 ),因此不需要额外进行防御性设置。
--json--jq '<expr>'jq--value is required in non-interactive mode.Preflight and signing in
预检与登录
Run , then . It reads (which wins over
a stored token) and confirms which user it resolves to, so it doubles as the auth check. It
fails with when there is no usable token.
circleci versioncircleci auth me$CIRCLE_TOKENNo CircleCI API token foundTo sign in, run . Don't ask the user for an API token: the OAuth
flow needs no secret from them, and pasting tokens into a chat is worse for them than a
browser round-trip. Without a terminal it opens the authorize page in the user's browser,
prints the same URL to stderr, then blocks for up to 5 minutes waiting for approval:
circleci auth login- Run it in the background, or with a timeout well above your default, not in a foreground call that gives up after a minute or two.
- Tell the user to approve the request in their browser, and pass along the printed URL in case the window never came to the front. They are watching you, not your tool output.
- Once they have approved, confirm with .
circleci auth me
--no-browserCICIRCLE_NO_INTERACTIVECIRCLE_TOKEN运行 ,然后运行 。它会读取 (其优先级高于已存储的 token),并确认该 token 对应哪个用户,因此也可作为 auth 检查。找不到可用 token 时,会报出 。
circleci versioncircleci auth me$CIRCLE_TOKENNo CircleCI API token found要登录,请运行 。不要向用户索要 API token:OAuth flow 不需要用户提供任何 secret;在聊天中粘贴 token 反而比通过浏览器完成一次授权更不安全。没有终端时,它会在用户浏览器中打开授权页面,将同一 URL 打印到 stderr,然后最多阻塞 5 分钟等待批准:
circleci auth login- 在后台运行它,或设置远高于默认值的 timeout;不要放在默认一两分钟后放弃的前台调用中。
- 告知用户在浏览器中批准请求,并转发打印出的 URL,以防窗口未自动置前。用户关注的是你的说明,而不是工具输出。
- 用户批准后,运行 进行确认。
circleci auth me
--no-browserCICIRCLE_NO_INTERACTIVECIRCLE_TOKEN1. Before you commit — validate locally (fast feedback)
1. 提交前——在本地验证(快速反馈)
bash
circleci config validate # lint .circleci/config.yml (default path); use -c <path> or - for stdin
circleci config process .circleci/config.yml # expand orbs/params → the final compiled config
circleci config process .circleci/config.yml --pipeline-parameters params.yml # process with pipeline params- is needed to resolve private orbs.
validate --org gh/<org> - previews upcoming (potentially breaking) config changes.
-n/--next - Scaffold a starter config for a new repo: (won't overwrite).
circleci config generate [path]
Handy git hook — block a push when the config is invalid ():
.git/hooks/pre-pushbash
#!/bin/sh
circleci config validate || { echo "Fix .circleci/config.yml before pushing"; exit 1; }bash
circleci config validate # lint .circleci/config.yml (default path); use -c <path> or - for stdin
circleci config process .circleci/config.yml # expand orbs/params → the final compiled config
circleci config process .circleci/config.yml --pipeline-parameters params.yml # process with pipeline params- 解析 private orbs 时需要使用 。
validate --org gh/<org> - 可预览即将推出(可能破坏兼容性)的 config 变更。
-n/--next - 为新 repo 生成 starter config:(不会覆盖已有文件)。
circleci config generate [path]
实用的 git hook——当 config 无效时阻止 push():
.git/hooks/pre-pushbash
#!/bin/sh
circleci config validate || { echo "Fix .circleci/config.yml before pushing"; exit 1; }2. Commit, push, and watch the run it triggers
2. Commit、push,并观察其触发的 run
bash
git push # your trigger fires a run
circleci run watch # watch the latest run on the current branch; blocks to completion
circleci run watch --sha "$(git rev-parse HEAD)" # match the run for THIS commit (polls up to 2m for it to appear)
circleci run watch --failfast # bail the moment any job failsrun watch--timeoutgit push && circleci run watch --sha "$(git rev-parse HEAD)"bash
git push # your trigger fires a run
circleci run watch # watch the latest run on the current branch; blocks to completion
circleci run watch --sha "$(git rev-parse HEAD)" # match the run for THIS commit (polls up to 2m for it to appear)
circleci run watch --failfast # bail the moment any job failsrun watch--timeoutgit push && circleci run watch --sha "$(git rev-parse HEAD)"3. Review your pipelines / runs
3. 审查 pipeline / run
bash
circleci run list # recent runs for this project (--limit, -b <branch>, -B current branch)
circleci run get # latest run on current branch: workflows → jobs, with status
circleci run get <run-id> # a specific run
circleci my runs # YOUR recent runs across every project you can access
circleci run open # open the current branch's run in the browserrun get--jsonworkflows[].idworkflows[].jobs[].idbash
circleci run list # recent runs for this project (--limit, -b <branch>, -B current branch)
circleci run get # latest run on current branch: workflows → jobs, with status
circleci run get <run-id> # a specific run
circleci my runs # YOUR recent runs across every project you can access
circleci run open # open the current branch's run in the browserrun get--jsonworkflows[].idworkflows[].jobs[].id4. Drill into a failure
4. 深入排查失败
bash
circleci run get --json --jq '.workflows[].jobs[] | select(.current_outcome=="failed") | {name,id}' # failing jobs + UUIDs
circleci job output list <job-id> # per-step logs (rendered; --tail N, default last 200 lines/step)
circleci job output get <job-id> --step-num <N> # full output of one step (--execution <i> for parallel runs)
circleci job get <job-id> # job metadata (status, timing, parallelism)
circleci testresult list <job-id> # FAILED tests only by default (--all, --filter result=…, --sort, --limit)
circleci job artifact <job-id> # list artifacts; -o <dir> to download themParallel jobs: targets one shard.
job output list --execution <index>bash
circleci run get --json --jq '.workflows[].jobs[] | select(.current_outcome=="failed") | {name,id}' # failing jobs + UUIDs
circleci job output list <job-id> # per-step logs (rendered; --tail N, default last 200 lines/step)
circleci job output get <job-id> --step-num <N> # full output of one step (--execution <i> for parallel runs)
circleci job get <job-id> # job metadata (status, timing, parallelism)
circleci testresult list <job-id> # FAILED tests only by default (--all, --filter result=…, --sort, --limit)
circleci job artifact <job-id> # list artifacts; -o <dir> to download them对于并行 job: 可定位到某个 shard。
job output list --execution <index>5. Act on a run
5. 对 run 执行操作
bash
circleci workflow rerun <workflow-id> # rerun the whole workflow from scratch
circleci workflow rerun <workflow-id> --from-failed # rerun only the failed jobs (workflow IDs come from `run get`)
circleci run cancel <run-number-or-id> # stop a run (-f to skip the prompt)
circleci run trigger # manually trigger a run (current project/branch)
circleci run trigger -b <branch> --parameter deploy=true --parameter tier=2 # trigger with params (repeatable)
circleci workflow cancel <workflow-id> # cancel a single workflowTo debug interactively (SSH into a job), rerun with SSH from the web app — there is no
CLI flag for it; gets you there fast.
circleci run openbash
circleci workflow rerun <workflow-id> # rerun the whole workflow from scratch
circleci workflow rerun <workflow-id> --from-failed # rerun only the failed jobs (workflow IDs come from `run get`)
circleci run cancel <run-number-or-id> # stop a run (-f to skip the prompt)
circleci run trigger # manually trigger a run (current project/branch)
circleci run trigger -b <branch> --parameter deploy=true --parameter tier=2 # trigger with params (repeatable)
circleci workflow cancel <workflow-id> # cancel a single workflow如需以交互方式调试(通过 SSH 进入 job),请从 Web 应用中带 SSH 重跑——CLI 没有对应 flag; 可以快速进入该页面。
circleci run openTroubleshooting — where to get each piece of information
故障排除——从哪里获取各类信息
| You want to know… | Command |
|---|---|
| Did my push build? Which run? | |
| Overall status of the latest run | |
| Which workflow/job failed | |
| Why a step failed (logs) | |
| Which tests failed | |
| Build outputs / reports | |
| Config problem before pushing | |
| Config error in the UI vs local | validate with |
| Everything I triggered lately | |
| Open it in the browser | |
| Env var names on the project | |
| Contexts in the org, and their secrets | |
| Pipeline definitions, and their triggers | |
| Anything not listed here | |
| CircleCI feature/config syntax question | use the circleci-config skill / docs MCP rather than guessing |
| 你想了解什么…… | 命令 |
|---|---|
| 我的 push 是否触发了 build?对应哪个 run? | |
| 最近一次 run 的整体状态 | |
| 哪个 workflow/job 失败了 | |
| 某一步为何失败(日志) | |
| 哪些测试失败 | |
| 构建产物/报告 | |
| push 前的 config 问题 | |
| UI 中与本地出现的 config 错误 | 使用 |
| 我最近触发的一切 | |
| 在浏览器中打开 | |
| 项目中的 env var 名称 | |
| 组织中的 contexts 及其 secrets | |
| Pipeline definitions 及其 triggers | |
| 这里未列出的内容 | |
| CircleCI feature/config 语法问题 | 使用 circleci-config skill / docs MCP,不要猜测 |
Gotchas
常见陷阱
- Commands default to the git remote's project and your current branch — into the repo. Override with
cdand--project gh/<org>/<repo>when outside it (note:-b <branch>/run getdefault the branch torun openwhenmainis set, not your checkout).--project - polls up to 2 minutes for the run to appear — expected right after a push.
run watch --sha - Logs, tests, and artifacts key off the job UUID (from /
run get --json), not the job number.workflow get - takes a run number or UUID; pass
run cancelwhen cancelling by number.--project - resolves relative to
circleci api <path>; a path starting with/api/v3is sent as given. Reach for it only when no command covers what you need:apisays which endpoints have one.references/api-coverage.mdand{project-id}in the path are filled in from the git remote.{org-id} - One execution of a pipeline is a run (,
run list).run getmanages pipeline definitions, the config and checkout sources a run executes, socircleci pipelineis not where runs live.pipeline list - Don't confuse (this skill: fire a run on the inferred project/branch) with
run trigger(definition-targeted; see the onboarding skill).pipeline run --definition-id … - Verify a real run + /
job output— a green status alone doesn't prove the step did what you intended.testresult
- 命令默认使用 git remote 的 project 和当前 branch——请先 进入 repo。在 repo 外时,使用
cd和--project gh/<org>/<repo>覆盖默认值(注意:设置-b <branch>后,--project/run get的默认 branch 是run open,而不是 checkout 的分支)。main - 最多会轮询 2 分钟以等待 run 出现——push 后立即出现属于正常现象。
run watch --sha - 日志、测试和 artifacts 都以 job UUID 为键(来自 /
run get --json),而不是 job 编号。workflow get - 接受 run number 或 UUID;按 number 取消时需传入
run cancel。--project - 会相对于
circleci api <path>解析;以/api/v3开头的 path 会按原样发送。仅当没有命令覆盖所需功能时才使用它:api会说明哪些 endpoints 有对应命令。path 中的references/api-coverage.md和{project-id}会根据 git remote 自动填充。{org-id} - pipeline 的一次执行是 run(、
run list)。run get管理的是 pipeline definitions,即 run 执行时使用的 config 和 checkout sources,因此 run 不在circleci pipeline中。pipeline list - 不要混淆 (本 skill:在推断出的 project/branch 上触发 run)与
run trigger(面向 definition;参见 onboarding skill)。pipeline run --definition-id … - 验证真实 run 以及 /
job output——仅凭绿色状态无法证明该步骤确实执行了你预期的操作。testresult
Guardrails
防护准则
- Read before you mutate. Prefer read-only commands (/
run get,list,job output,testresult) beforejob artifact/rerun/trigger, and confirm the organization/project scope before mutating pipeline state.cancel - Never print raw secret values from environment variables or tokens. Pipe secrets from
/stdin — never pass them as command-line args (they leak into shell history and logs).
op read - Don't invent commands. Verify with first; if a subcommand isn't listed, don't use it. There is no top-level
circleci help: firing a run istrigger, andrun triggermanages the triggers attached to a definition. On older builds that lackproject trigger, read cloud job logs from the CircleCI app/UI or connected CircleCI MCP tooling.api - If auth/permissions fail, report the exact scope gap and safest remediation
(, refresh permissions in User Settings) rather than retrying blindly.
circleci auth login
- 先读取,再修改。 在 /
rerun/trigger前,优先使用只读命令(cancel/run get、list、job output、testresult),并在修改 pipeline 状态前确认 organization/project 范围。job artifact - 绝不打印环境变量或 token 中的原始 secret 值。 通过 /stdin 传入 secrets——绝不要将其作为命令行参数传递(否则会泄露到 shell history 和 logs 中)。
op read - 不要臆造命令。 先用 验证;如果没有列出某个 subcommand,就不要使用。不存在顶层
circleci help:触发 run 的命令是trigger,而run trigger管理附加到 definition 上的 triggers。在缺少project trigger的旧版本中,应从 CircleCI app/UI 或已连接的 CircleCI MCP tooling 读取 cloud job logs。api - 如果 auth/permissions 失败,应报告具体的权限范围缺口和最安全的修复方式(、在 User Settings 中刷新权限),不要盲目重试。
circleci auth login
Telling CircleCI when the CLI falls short
何时向 CircleCI 反馈 CLI 的不足
circleci feedback- An error that looks like CircleCI's fault: a 5xx, or anything the CLI follows with
.
If this looks like a CircleCI problem, report it: circleci feedback … - A missing capability: no command covers what you needed, even after checking
and
circleci help.references/api-coverage.md - Confusing output: you misread it, or it contradicted what you found elsewhere.
bash
circleci feedback "run get --json listed no jobs for a run the web app shows with three" --tool "run get"- Say what you were trying to do, what you ran and what happened, quoted as one argument.
names the command it's about.
--tool - The report carries the user's CircleCI identity, so describe the CLI's behavior in your own words and keep secrets, env var values and log excerpts out of it.
- Problems in the user's config or code, or a missing token or permission, belong to the user, not in a report.
- Send one report per problem, then carry on with the task. If fails, or
feedbackdoesn't list it, move on without it.circleci help
circleci feedback- 看起来是 CircleCI 自身问题的错误:5xx,或 CLI 在其后提示 的任何错误。
If this looks like a CircleCI problem, report it: circleci feedback … - 缺少能力:即使检查了 和
circleci help,仍没有命令覆盖所需功能。references/api-coverage.md - 输出令人困惑:你无法解读,或它与其他位置发现的信息相矛盾。
bash
circleci feedback "run get --json listed no jobs for a run the web app shows with three" --tool "run get"- 说明你尝试做什么、运行了什么以及发生了什么,并将其作为单个加引号的参数传入。指定相关命令。
--tool - 报告会携带用户的 CircleCI identity,因此请用自己的话描述 CLI 行为,并且不要在报告中包含 secrets、env var 值和 log excerpts。
- 用户 config 或代码中的问题,以及缺少 token 或权限,属于用户侧问题,不应提交报告。
- 每个问题发送一份报告,然后继续任务。如果 调用失败,或
feedback未列出该命令,则跳过并继续。circleci help
Report back
汇报结果
When you finish, summarize:
- Commands run and their purpose.
- Key outputs — pipeline/workflow/job ids, status, failing step.
- Actions taken (rerun/trigger/validate) and why.
- Remaining blockers and the next recommended CLI command.
- Any feedback you sent to CircleCI, and what it said.
完成后,请总结:
- 执行过的命令及其目的。
- 关键输出——pipeline/workflow/job IDs、状态、失败步骤。
- 已执行的操作(rerun/trigger/validate)及其原因。
- 剩余阻塞项以及建议的下一条 CLI 命令。
- 发送给 CircleCI 的任何反馈及其回复。