Skip to Content
HeyBug docs
CLI

CLI exit codes

Use exit codes to gate a build on a run.

Use exit codes to gate a build on a run. heybug runs wait follows a run until it ends, then exits with a code your CI step can read. The same codes come back from heybug runs start and heybug ci run.

What it is for

A script or CI job needs one answer: did the run pass, did it fail, or did something stop us from knowing. The exit code gives that answer without parsing text. The text on stderr explains the reason in plain words.

Exit codes

CodeNameMeaningWhat to do
0PassedThe run finished and every test passed.Continue the pipeline.
1Tests failedA test failed, was blocked or was cancelled.Open the dashboard link printed for the run.
2UsageAn unknown flag, or a missing value or argument.Read the usage line and fix the command.
3Not signed inCredentials are missing, invalid or expired.Run heybug auth status, then sign in again.
4Not foundThe project, run or result does not exist.Check the id and the project.
5Invalid inputThe input was rejected, or a CI gate found nothing to run.Fix the flags. Use --allow-skip only if an empty run is fine.
6Run wait timed outThe wait ran out of time. The run keeps going. Code 6 also covers a server or network error.Wait again with the run id. Read the message to tell the two apart.
7Rate limitedThe server asked us to slow down.Retry after a short pause.
12CreditsThe account has no credits left.Add credits, then run again.
13Plan gateThe feature is not in the current plan.Ask the workspace owner about the plan.
130InterruptedYou pressed Ctrl-C.Start the run again, or run heybug runs cancel.

Code 6 is the only code that can mean "not done yet". Treat it as a retry, not as a failure of the app under test.

Steps

  1. Start the run. Pass --no-wait to get the run ids and return at once, or leave it out to follow the run in the same command.
  2. Wait for the run with heybug runs wait <runId>. Set --timeout to the longest time your job can spend. The default is 30 minutes. The flag takes a duration such as 30m.
  3. Read the exit code. Stop the pipeline on any code except 0.
  4. If you need the details, open the dashboard link. You can also read the run with GET /api/runs/{runId} and a signed-in token.

runs start --timeout takes seconds, not a duration. ci run waits without a time limit.

Example

Start a run in a CI step, wait for it, and branch on the code:

run=$(heybug runs start --project p_1 --env staging --no-wait --output json | jq -r '.runs[0].runId')
heybug runs wait "$run" --timeout 30m --output json
code=$?
case "$code" in
  0) echo "Passed" ;;
  1) echo "Tests failed. Open the dashboard link above." ;;
  6) echo "Wait timed out or the server could not be reached." ; exit 6 ;;
  *) echo "Setup problem. Read the message above." ; exit "$code" ;;
esac

For a single gate without a separate start step, heybug ci run --project p_1 --env staging --report junit waits for every run it starts. Add --allow-skip when an empty selection should pass.

An AI agent connected through MCP does not get an exit code. Its heybug_get_run tool takes a wait value of up to 45 seconds and returns the status as text. Call it again until the run is finished.

When it fails

  • Code 6 and "Timed out; the runs are still going." Nothing was cancelled. Run heybug runs wait <runId> again with a longer --timeout, or open the dashboard.
  • Code 6 with a connection error. The server was not reachable. Check --server, then run heybug doctor.
  • Code 3. Run heybug auth status. In CI, set HEYBUG_TOKEN from a secret. Do not print it in the log.
  • Code 130. Ctrl-C cancels the runs that runs start began, unless you passed --detach. Use --detach in long jobs where runs should keep going after the job stops.
  • Code 5 with "Skipped: no tests were selected". Nothing matched the filter. Check the filter, or pass --allow-skip in ci run.

See also CLI for install and sign-in, and CI for the workflow that calls these commands.

On this page