CI & tryjobs (gh run)#
pw_ghish: GitHub CLI-like interface for Gerrit code reviews and CI checks
./gh run and ./gh pr checks map GitHub Actions CLI workflows to LUCI
Buildbucket and Android Busytown / TreeHugger (ci.android.com). You
can check build statuses, inspect step execution trees, view step failure logs,
and rerun failed tryjob or presubmit builders from the terminal.
Quick reference#
# Check status and duration of LUCI tryjob or Busytown builders on the active CL:
$ ./gh pr checks
# Watch checks until completion, exiting with failure logs if a check fails:
$ ./gh pr checks --watch --fail-fast
# View a summary of all tryjobs on the active CL:
$ ./gh run view
# Inspect the step execution tree and failure summaries for a builder:
$ ./gh run view -j pigweed-lintformat
# Print failure summaries and step log snippets for all failed checks:
$ ./gh run view --log-failed
# Rerun all failed builders on the active CL:
$ ./gh run rerun --failed
Overview: pr checks and gh run#
Matching the GitHub CLI, pw_ghish divides CI commands into two groups:
Change-level check status (
./gh pr checks): Displays a status table for a Gerrit CL, supports polling until completion (--watch), and returns an exit code suitable for shell pipelines and merge gates.Run and builder inspection (
./gh run): Inspects individual LUCI or Busytown builders and step execution trees (run view -j <builder>), fetches failure logs (--log-failedand--log), and triggers builder retries (run rerun).
Both pr checks and run commands resolve the active Gerrit change from
your current Git branch or HEAD commit when no target argument is supplied.
You can also pass an explicit change number (e.g. 472267), patchset suffix
(e.g. 472267/3), Gerrit URL/shortlink (see
Targeting changes), a Buildbucket build ID (e.g.
8671182706745774001), or a Busytown build ID and target (e.g.
P99164207/target_name or P99164207 --target target_name).
Checking and watching CL status: pr checks#
./gh pr checks queries the active CI provider (LUCI Buildbucket and/or
Android Busytown) to display the status, duration, and build URLs of checks on a
change:
# Check active change on current branch:
$ ./gh pr checks
# Check a specific change by number:
$ ./gh pr checks 413992
Checks for Change 413992 (Patchset 1)
✓ static-checks-pigweed 16s https://ci.chromium.org/b/8680709829694997521
Verdict: PASSED (1 check passed)
Next: gh pr view 413992
# Check a historical patchset:
$ ./gh pr checks 413992/1
The default output ends with the same Verdict:/Next: footer as
gh run list (FAILED, CANCELED, PENDING, NO CHECKS, or
PASSED); while checks are running, Next: suggests
gh pr checks <id> --watch --fail-fast. Because the footer already names the
next step, the Error: line on stderr is then a one-line summary;
--json and --template output has no footer and keeps the full
remediation text in the error.
By default, non-blocking experimental builders (cq_experimental) are
omitted from the display. Pass --experimental (or -e) to include them.
When more than 5 passing checks are present, pr checks and run view
order failing, in-progress, and canceled checks first and collapse passing
checks into a single summary line (<N> passing checks omitted (use --all to
list)). When ci.hide_tag_filters is configured in .ghish.toml or
git config (for example, hide-in-gerrit:subbuild on orchestrator
builds), matching child subbuilds are also hidden by default and can be shown
with --all:
$ ./gh pr checks --experimental
$ ./gh pr checks 413992 -e
$ ./gh pr checks --all
Gerrit gates, Busytown / TreeHugger, and dual-stack CI#
In addition to LUCI Buildbucket tryjobs, ./gh pr checks and ./gh run
support Android Busytown / TreeHugger (ci.android.com) and Gerrit
SubmitRequirements / automated verification labels (such as
Presubmit-Verified, Android-Build-Verified, Lint-Verified,
Tree-Approval, and Kokoro):
Android Busytown / TreeHugger (
busytown): Automatically enabled on Android Gerrit hosts (*android-review.googlesource.com,ag/...,aosp/...), on changes withPresubmit-Ready/Autosubmitlabels orTreeHuggermessages, or whenci.providersincludes"busytown"in.ghish.toml. Queries Gerrit’streetop~presubmittasksendpoint for structured per-target statuses and falls back to parsingTreeHuggerGerrit messages andPresubmit-Verifiedvotes whentreetop~is unavailable.Dual-stack repositories (
ci.providers = ["buildbucket", "busytown"]): Queries both LUCI Buildbucket and Busytown in parallel, merges their check items into a single table and JSON response, and routesrun viewandrun rerunto the appropriate provider per build.Gerrit Submit Requirements and gates: Unsatisfied or non-Buildbucket Gerrit gates are rendered in a
Gerrit Gates / Submit Requirements:section and included in the JSON output and exit code evaluation. On repositories that use only Gerrit labels (ci.providers = ["gerrit"]),./gh pr checksevaluates Gerrit verification labels and submit requirements directly.
Watching checks: --watch and --fail-fast#
Use --watch (-w) to poll until all blocking checks finish. Combine with
--fail-fast to exit as soon as any blocking check fails. By default,
failing checks print their step failure summary and log snippet upon exit:
# Watch until all blocking checks complete (default 15s interval):
$ ./gh pr checks --watch
# Exit on first check failure and print step failure logs:
$ ./gh pr checks --watch --fail-fast
# Custom poll interval (e.g. every 30s):
$ ./gh pr checks --watch --fail-fast --interval 30s
# Open checks overview in web browser:
$ ./gh pr checks --web
# Output JSON:
$ ./gh pr checks --json checks,submitBlockers
In --json output, each entry in checks and gerritGates reports its
state in status (Buildbucket statuses such as SUCCESS or FAILURE;
submit-requirement statuses such as SATISFIED, UNSATISFIED,
APPROVED, or REJECTED). The ✓/✗ glyphs in text output are
display-only and are not part of the JSON.
Process exit code contract#
./gh pr checks reports the state of the change through its process exit
code, matching the GitHub CLI:
Exit code |
Meaning |
|---|---|
|
At least one blocking check ran and all of them passed. |
|
Nothing has failed, but at least one blocking check is still running. |
|
At least one blocking check failed or was canceled, no checks were reported at all, or the command itself errored. |
Exit 0 reflects CI only; when submit requirements such as Code-Review are
still unsatisfied, the text output ends with a Not yet submittable: line and
--json reports them in submitBlockers (empty when none).
The contract holds on every invocation, with or without --watch,
--json, or --template, so it is safe to use as a merge gate:
$ ./gh pr checks --watch && ./gh pr merge --cq
A change with no reported checks exits 1, because
CI that was never scheduled is not CI that passed. Experimental (non-blocking)
builders never affect the exit code, even with --experimental, since the
Commit Queue does not gate on them; --experimental only controls what is
displayed.
Canceled checks on superseded patchsets#
Canceled checks exit 1 as well, since a canceled build did not pass, but
they are reported as canceled rather than failed. Querying an older patchset
usually produces them, because uploading a new patchset cancels the runs still
in flight on the previous one:
$ ./gh pr checks 472267/43
...
Verdict: CANCELED (29 of 75 checks canceled, likely superseded by a newer patchset)
Next: gh pr checks 472267 (or gh pr edit 472267 --cq)
Error: 29 of 75 checks were canceled on Change 472267 (Patchset 43): ... and 24 more.
With --json or --template there is no Verdict:/Next: footer, so
the error instead carries the full remediation text (why checks get canceled,
and the commands to query the current patchset or start a fresh dry run).
Reused builds from equivalent earlier patchsets#
When a new patchset is uploaded without changing code—such as a trivial rebase
(TRIVIAL_REBASE or TRIVIAL_REBASE_WITH_MESSAGE_UPDATE), a commit-message
edit (NO_CODE_CHANGE), NO_CHANGE, or MERGE_FIRST_PARENT_UPDATE—LUCI
CV keeps tryjob results from the earlier patchset instead of rerunning every
builder.
pr checks, pr view, pr status, and gh run walk backwards across
these code-equivalent patchsets (stopping at the most recent REWORK) and
include their builds:
Builds reused from an earlier patchset are annotated with
(from patchset <N>)inpr checks,run list,run view, and failure reports, and carry apatchsetfield in--jsonoutput (alongsideequivalentPatchsetsonpr checks --jsonandrun view --json).When multiple equivalent patchsets have builds for the same builder, the newest build is shown—except when the newest build was
CANCELEDand an earlier equivalent build succeeded, in which case the passing build is kept.
Inspecting and rerunning builds: gh run#
Listing runs: run list#
Lists all checks and tryjobs for a change, or recent postsubmit/roller builds
for one or more LUCI builders via -w, --workflow (pass --all to include
subbuilds hidden by ci.hide_tag_filters):
# List runs for active change:
$ ./gh run list
# List runs for a specific change:
$ ./gh run list 472267
# List recent postsubmit or roller builds for a LUCI builder:
$ ./gh run list -w pigweed/pigweed.ci/pigweed-linux-bazel-host -L 5
$ ./gh run list -w pigweed/tools.roll/bloaty-roller -L 3 --status completed --json
# Batch-query multiple LUCI builders via Builds/Batch (repeatable or '-' stdin):
$ printf 'pigweed/pigweed.ci/a\npigweed/pigweed.ci/b\n' | ./gh run list -w - -L 3 --json
# Filter builds on an active CL by builder, limit (-L), or status (-s):
$ ./gh run list 472267 -w pigweed-linux-bazel-host -s failure -L 5
# Include non-blocking experimental checks or hidden subbuilds:
$ ./gh run list --experimental
$ ./gh run list --all
# Output JSON (returns flat []CheckItem array in both change and builder modes):
$ ./gh run list --json
Viewing runs, steps, and logs: run view#
./gh run view supports three modes of inspection:
1. Change-level run overview#
Running ./gh run view renders a summary of all builders on the change:
$ ./gh run view
Showing 10 checks for Change 467905 (Patchset 22) • docs: Integrate navs
Gerrit CL: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/467905
JOBS
✓ static-checks-pigweed (22s)
✓ pigweed-mac-arm-bazel-python (4m53s)
✓ pigweed-linux-gn-platform (10m48s)
✓ pigweed-linux-gn-host (8m55s)
✓ pigweed-linux-gn-compatibility-platform (10m4s)
✓ pigweed-linux-gn-compatibility-main (15m11s)
✓ pigweed-linux-bazel-python (1m24s)
✓ docs-builder (2m36s)
✓ docs-builder-newpatchset (3m15s)
X pigweed-lintformat (5m32s)
To view step execution details for a specific check, run:
gh run view -j <builder-name>
To inspect failure summaries and logs for failed checks, run:
gh run view --log-failed
2. Builder step execution tree (-j <builder>)#
Inspect the execution steps and timing of a specific builder on a change.
pw_ghish collapses passing internal recipe substeps into top-level phases,
highlights failing child steps, and extracts 1-line failure diagnostics (such
as formatting diffs or compiler errors):
$ ./gh run view -j pigweed-lintformat
Steps for pigweed-lintformat (Build 8671182706745774001)
Status: FAILURE ✗ | URL: https://ci.chromium.org/b/8671182706745774001
✓ setup_build running recipe: "pw_presubmit" with Python 3.11.9
✓ checkout pigweed
✓ environment
✓ get steps from programs
✓ bazel_format
✓ css_format
! javascript_format
└── ✗ failure summary: formatting diff in docs/common/header.js
✓ markdown_format
! python_format
└── ✗ failure summary: formatting diff in 3 files: header.py, nav.py, ...
✓ restructuredtext_format
Pass -v or --verbose to inspect all unfiltered recipe steps. When a
project schedules builders across multiple LUCI buckets, -j accepts either
the short builder name (-j <builder>), bucket-qualified selector
(-j <bucket>/<builder>), or full Buildbucket path
(-j <project>/<bucket>/<builder>).
3. Step failure logs (--log-failed and --log)#
Fetch failure summaries and raw step log snippets in the terminal:
# Inspect all failed checks on current change:
$ ./gh run view --log-failed
# Inspect a specific failed builder:
$ ./gh run view -j pigweed-lintformat --log-failed
# Inspect a Busytown build directly by build ID and target (--target is ghish-only):
$ ./gh run view P99164207/firmware_host_tests --log-failed
$ ./gh run view P99164207 --target firmware_host_tests --log-failed
# Print the full step log instead of the windowed failure snippet:
$ ./gh run view -j pigweed-lintformat --log
# Output JSON report:
$ ./gh run view --log-failed --json
# Batch-inspect multiple Buildbucket build IDs (positional or '-' stdin):
$ ./gh run view 8671182706745774001 8671182706745774002 --json
$ printf '8671182706745774001\n8671182706745774002\n' | ./gh run view - --log-failed --json
# Open build in web browser:
$ ./gh run view -j pigweed-lintformat --web
run view [<build-id>...] batches Buildbucket Builds/Batch
GetBuild requests for multiple numeric build IDs (or - via stdin),
returning a []LUCIBuildDetails JSON array in batch mode (or a single
LUCIBuildDetails object for one positional build ID) with steps,
input, and timestamps preserved.
On LUCI Buildbucket builds, run view --log-failed prioritizes curated
failure summary (or failure_summary) streams before falling back to
stdout and stderr (configurable via ci.preferred_logs in
.ghish.toml). When extracting a snippet, it strips ANSI/control sequences and
scans the full bounded log to anchor a window around the first high-signal
build/test error marker plus the non-overlapping tail summary (separated by
[... N lines omitted ...]; pass --log for the complete cleaned log).
For orchestrator builds where compilation or test failures occur in a child
subbuild, run view --log-failed also includes the top-level build
SummaryMarkdown (including reproduction hints such as fx repro) while
deduplicating truncated summary blocks against the full failure summary log
snippet.
On Android Busytown / TreeHugger builds, run view --log-failed uses a
two-tier retrieval strategy:
Local workstation accelerators (Tier A): Invokes
/google/data/ro/projects/android/fetch_artifact(to streambuild.log) and/google/data/ro/projects/android/ants_cli(to query failed AnTS test invocations) when present on the machine.Direct HTTP fallback (Tier B): Queries the Android Build Internal v3 REST API (
androidbuildinternal.googleapis.com) andci.android.comusing OAuth2 credentials, and extracts the failure snippet aroundFAILED:,: error:,: fatal error:, orninja: build stoppedmarkers.
Rerunning CI checks: run rerun#
Rerun specific or all failed builders on a change:
LUCI Buildbucket: Constructs and executes the
bb addinvocation using each build’s recorded Buildbucket<project>/<bucket>/<builder>tuple. Child subbuilds tagged withskip-retry-in-gerrit:subbuild(or matchingci.skip_retry_tag_filtersin.ghish.toml) are automatically skipped during--failedreruns so only top-level parent builders are scheduled.Android Busytown / TreeHugger: Triggers a presubmit rerun via Gerrit’s
POST /changes/<id>/revisions/<ps>/treetop~runaction?service-id=presubmit&action-id=runendpoint, automatically falling back to votingPresubmit-Ready+1if thetreetop~plugin is not installed on the Gerrit host.Dual-stack: When a change has failed builds on both Buildbucket and Busytown,
run rerun --failedtriggers both providers.
# Rerun all failed builders on the current change:
$ ./gh run rerun --failed
# Rerun a single builder on the current change:
$ ./gh run rerun -j pigweed-lintformat
# Rerun a builder on a specific change:
$ ./gh run rerun 472267 -j pigweed-mac-arm-vscode
# Preview the rerun command without executing:
$ ./gh run rerun --failed --dry-run
Watching runs: run watch#
Poll checks until all blocking builds complete:
$ ./gh run watch
$ ./gh run watch 472267 --interval 30s
Scanning LUCI consoles: run console#
./gh run console [<project>/<console>|<console>...] discovers console
builders dynamically from luci.milo.v1.MiloInternal/QueryConsoleSnapshots,
enriches experimental flags and description links via
buildbucket.v2.Builders/ListBuilders, and batch-queries recent builds via
buildbucket.v2.Builds/Batch. Pass --project <project> (repeatable) or
<project>/<console> selectors (supporting path.Match globs such as
pigweed.*); bare <console> selectors or omitted targets resolve the
default LUCI project from ci.try_buckets in .ghish.toml or the host
profile. Experimental builders (experimental: YES, .non_production, or
cq_experimental) are skipped unless -e, --experimental is passed,
-L, --limit and -s, --status filter fetched builds per builder,
--all / -v expands collapsed passing builders, and --json emits
the structured []ConsoleBuilderItem array.
# Scan all consoles in the default project or an explicit --project:
$ ./gh run console --project pigweed
# Scan qualified console selectors or globs and inspect failures in JSON:
$ ./gh run console 'pigweed/pigweed.*' -L 5 -s completed --json
Comparison with GitHub CLI (gh run & gh pr checks)#
Gerrit projects run LUCI Buildbucket and/or Android Busytown rather than GitHub
Actions. ./gh run and ./gh pr checks map these concepts as follows:
LUCI / Busytown vs. GitHub Actions concept map#
GitHub Actions Concept |
LUCI / Busytown Equivalent in |
Behavioral Notes |
|---|---|---|
Workflow Run |
Gerrit Patchset Tryjob Set (or Build ID) |
Identified by Gerrit change/patchset ( |
Workflow Job ( |
LUCI Builder or Busytown Target |
Targeted by builder/target name via |
Job Steps |
LUCI Recipe Steps / Busytown Target |
LUCI recipes emit nested substeps; |
Action Logs |
Buildbucket Step Logs / Busytown |
|
Rerun Workflow ( |
Buildbucket Retry ( |
Schedules tryjobs in Buildbucket or re-triggers TreeHugger presubmit on the patchset. |
Key behavioral and flag differences#
Change-scoped by default: In upstream
gh, runninggh run listorgh run viewwith no arguments queries recent workflow runs across the entire repository. Because a Gerrit repository has many concurrent tryjobs across unrelated changes,pw_ghishscopesrun list,run view,run watch, andrun rerunby default to the active Gerrit CL on your current branch.Fast failure logs on watch (
pr checks --watch --fail-fast): Exits--watchas soon as any blocking builder fails and automatically fetches the failing step logs.Experimental builders (
-e, --experimental): LUCI distinguishes blocking Commit-Queue builders fromcq_experimentalbuilders. Experimental builders are hidden by default and do not cause a non-zero exit code inpr checks.Equivalent patchset reuse: Tryjobs from earlier patchsets with no code changes (e.g.
TRIVIAL_REBASE,NO_CODE_CHANGE) are automatically included and annotated with(from patchset <N>), matching LUCI CV’s build reuse rules.--allflag (ghish-only): Onpr checks,run list, andrun view,--allexpands all individual passing checks without collapsing and includes child subbuilds hidden byci.hide_tag_filters.-w, --workflow <builder>: In upstreamgh,run list -wfilters by a GitHub Actions workflow name or YAML file. Here-w, --workflowqueries or filters LUCI Buildbucket builders (accepting<project>/<bucket>/<builder>,<bucket>/<builder>,luci.<project>.<bucket>/<builder>, or-onstdinforBuilds/Batchqueries). Both change mode and builder mode emit a flat[]CheckItemJSON array under--json.--target <target>flag (ghish-only): Onrun view,--targetspecifies the Android Busytown target name when inspecting a direct build ID (e.g.gh run view P99164207 --target firmware_host_tests --log-failed). It is long-form only because upstreamghreserves-tfor--template.--jsonflag: Onrun listandrun view,--jsonis a boolean flag that emits the structured run or failure report (unlikepr view --json <fields>andissue view --json <fields>, which take a comma-separated field list).
For the flag compatibility policy across all subcommands, see Compat policy.