Run from CI
A pipeline runs one command. It starts a batch on a saved environment, prints a line as each workflow finishes, and exits with a code the pipeline passes or fails on.
npx @belayqa/cli run --project "Switchback Cycles" --environment staging --tag smokeThe command is belay, from the npm package @belayqa/cli. It needs Node 20.3 or later and installs nothing else.
It runs the workflows saved in Belay, or the workflows’ files kept in your repository: see Workflow files.
The key
Section titled “The key”The command reads two environment variables.
| Variable | |
|---|---|
BELAY_API_KEY |
Your organization’s API key. Required. Keep it in the pipeline’s secrets. The command never takes the key as an argument and never prints it. |
BELAY_URL |
Belay’s address, when it is not https://app.belayqa.com. |
Make the key on the organization’s API keys page. Name it for the pipeline that uses it, because batches it starts show that name as who started them.
GitHub Actions
Section titled “GitHub Actions”Use the action belay-qa/run:
- uses: belay-qa/run@v1 with: api-key: ${{ secrets.BELAY_API_KEY }} project: Switchback Cycles environment: staging tag: smoke| Input | |
|---|---|
api-key |
The organization’s API key. Required. Pass it from a secret. |
project |
The project, by name or id. Required, except when workflow is an id. |
environment |
The saved environment to run on, by name or id. Required. |
tag, folder, all, workflow, files |
What to run. Give exactly one. all: true runs every workflow in the project; workflow is one workflow’s id or its exact name; files is the workflow files to run, one path per line, from the repository’s root. |
update |
true saves the files to the project before running them, for the job that releases. It needs a key that can update workflows. |
url |
Belay’s address, when it is not https://app.belayqa.com. |
timeout-minutes |
How long to wait for the result. 60 when left out. |
Or run the command in a step:
- run: npx @belayqa/cli run --project "Switchback Cycles" --environment staging --tag smoke env: BELAY_API_KEY: ${{ secrets.BELAY_API_KEY }}Either way, on GitHub Actions it also writes a job summary, with the result, the counts, a table of what did not pass with links to the runs, and a link to the batch. It sets the step’s outputs batch-id, result (passed, failed, or incomplete, or running when it stopped waiting first), and url, the batch’s page. For a single workflow it sets run-id, result as the run’s outcome, and url as the run’s page instead. For a batch it sends the commit, the branch, and a link to the workflow run, which the batch’s page shows.
Any other pipeline
Section titled “Any other pipeline”Run the command with BELAY_API_KEY set from the pipeline’s secret variables. On GitLab CI:
belay: image: node:24 script: - npx @belayqa/cli run --project "Switchback Cycles" --environment staging --tag smokeAdd BELAY_API_KEY as a masked CI/CD variable. On GitLab the commit, the branch, and the pipeline’s link are sent too. Anywhere else, pass them with --commit, --branch, and --link.
What to run
Section titled “What to run”belay run takes --project and --environment, by name or id, and exactly one of these:
| Option | Runs |
|---|---|
--tag <tag> |
Every workflow with the tag. |
--folder <folder> |
Every workflow in the folder. |
--all |
Every workflow in the project. |
--workflow <workflow> |
One workflow, by its id (wf-…) or its exact name. With an id, --project can be left out. |
<paths> |
The workflow files at these paths, after the options. |
A batch it starts follows every rule of Batches. Its other options:
| Option | |
|---|---|
--no-wait |
Start it, print its id and link, and exit 0 without waiting. |
--timeout <minutes> |
How long to wait for the result. 60 when left out. |
--json |
Print the final batch or run as the API gives it on standard output, or with --no-wait the start’s answer. The progress lines go to standard error. |
--commit, --branch, --link |
What the pipeline is building, shown on the batch’s page. Filled in on GitHub Actions and GitLab CI; an option replaces what was found. A single workflow’s run doesn’t record them, so they are refused with --workflow. |
What it prints
Section titled “What it prints”A line as each workflow finishes. A workflow that did not pass shows the step it stopped at, why, and a link to its run. At the end come the result, the counts, what changed since the last batch, and the batch’s link. A batch of the tag nightly that failed, as the command printed it:
Started batch batch-e078dfe5-e6f6-483b-89d7-318d26b6f3f6: 2 workflowsBatch: https://app.belayqa.com/projects/6d8dc203-3bdc-4c6a-8dce-9321a895f86b/batches/batch-e078dfe5-e6f6-483b-89d7-318d26b6f3f6[1/2] Passed Add a customer 1s[2/2] Failed Customer grid lists Umbrella 11s (still not passing) Step: Verify that "Umbrella Corporation" appears in the customer grid. Why: Not in the customer grid. Link: https://app.belayqa.com/projects/6d8dc203-3bdc-4c6a-8dce-9321a895f86b/runs/run-d10f36e9-b749-456e-b09f-9d09b1962b7d
Failed · Tag nightly on staging · 12s1 passed, 1 did not pass of 2 workflowsSince the last batch: 1 still not passing, 1 still passingBatch: https://app.belayqa.com/projects/6d8dc203-3bdc-4c6a-8dce-9321a895f86b/batches/batch-e078dfe5-e6f6-483b-89d7-318d26b6f3f6When the step was one of a routine’s, its place and the routine follow the sentence, as the run’s page names it:
Step: Click the Launch Rocket button. (step 1.2, in Launch)The words for each outcome are the ones Belay’s pages use, as listed on Outcomes. A workflow that can’t run is listed as Can’t run, with why. Colour is used only on a terminal, and never when NO_COLOR is set.
Workflow files
Section titled “Workflow files”When your team keeps its workflows as files in the repository, the pipeline sends them with the run. Two pipelines use them:
- A pull request runs the files on its branch and saves nothing, so a change to your application and to its tests is tested with its own tests.
- The release adds
--update: it saves the files to the project, then runs them, so the saved workflows, and the schedules that run them, follow what was released.
# A pull requestnpx @belayqa/cli run --project "Switchback Cycles" --environment staging belay
# The releasenpx @belayqa/cli run --project "Switchback Cycles" --environment production --update belayThe paths come after the options. A path is a file, a folder (every .yaml and .yml file in it and in the folders under it), or a pattern with * (any part of one name) and ** (any number of folders), such as "belay/**/*.yaml". The command matches patterns itself, so they work in a shell that does not, as long as they are quoted. A walk through a folder leaves out hidden folders, such as .git, and node_modules. Every path must find a file: a path that does not exist, a pattern that matches nothing, or a folder with no workflow files is refused before anything is sent, so a test is never left out without a word. A file named directly must end in .yaml or .yml.
Each file is sent with its path from the folder the command runs in, and what Belay says about a file names it by that path. The command reads no YAML itself: Belay reads the files. At most 500 files, and 4 MB of them, go in one run.
A run of the files
Section titled “A run of the files”Found 3 workflow files.Started batch batch-e078dfe5-e6f6-483b-89d7-318d26b6f3f6: 3 workflowsBatch: https://app.belayqa.com/projects/6d8dc203-3bdc-4c6a-8dce-9321a895f86b/batches/batch-e078dfe5-e6f6-483b-89d7-318d26b6f3f6[1/3] Passed Buy a helmet 9s (ran the file's steps)A workflow that ran its file’s own steps, because the file differs from the saved workflow or has none, says “(ran the file’s steps)”. The batch is named for the branch, such as “Files from coupon-field”, and is compared with the last batch of files from the same branch on the same environment. Each file is one workflow of the batch, as Workflows as files says.
A routine’s file (kind: routine) is sent with the others and counted among the files found, but never runs as a workflow of the batch: the workflows’ files are read with it in place of the saved routine.
A file with a step that needs a change does not start, and the batch says which step, by its place and its line in the file:
Step 2, on line 5, needs a change, so this file can’t run. Change it in the file; belay check says why.
--update
Section titled “--update”--update takes paths only, and needs a key made to Run workflows and update them from files (API keys). It checks the environment, saves the files, says what changed, and then runs the batch. The files are now the same as their workflows, so every run is an ordinary run of a saved workflow:
Found 17 workflow files.Saved 17 workflow files: 1 new, 2 updated, 14 unchanged.Replaced an edit made in the app to Buy a helmet by Robin Lee on 2026-11-12 16:02 UTC (belay/checkout/buy-a-helmet.yaml).Started batch batch-…: 17 workflowsA Replaced an edit made in the app line names each workflow someone had saved in the app since a pipeline last sent its file, or ever, if none had. Belay keeps no copy of the replaced steps, so this line is the only record of them. A step that needs a change is saved, listed as belay check lists it, and its workflow does not start.
When the save is refused, nothing is saved and nothing runs, and the command exits 3: a file that cannot be read, a step that could not be read at all, a file with more steps than your plan allows, more new workflows than your plan has room for, or a key that can’t update workflows:
This key can’t update workflows. Make one that can on Organization, API keys.
If the save went through and the start was then refused, such as by a run limit, the command says “The files were saved, but the batch did not start.” and exits 3. Run it again once runs can start: the save then changes nothing, and the batch starts.
On GitHub Actions the job summary also says what the save did, under Saved from the files.
A file that cannot be read
Section titled “A file that cannot be read”When a file cannot be read, nothing starts, and every problem is listed as the file’s path, its line, and what to change, then the command exits 3. With --update the first line says “nothing was saved and nothing was started”.
belay: A file could not be read, so nothing was started:belay/repairs/book-a-repair.yaml:7: Put this step in single quotes. YAML read it as something other than a sentence, because of a ': ' in it or a mark at its start.belay check
Section titled “belay check”belay check --project <project> <paths> reads the files as --update would, and says what a save would change and each step that needs a change, without saving or running anything. Any key can check. Run it before you commit, or in a pull request, to catch a step that needs a change or a missing quote early.
Checked 3 workflow files: a save would add 1 and leave 2 unchanged.belay/checkout/buy-a-helmet.yaml:12: Does more than one thing: Click Save and check that "Saved" is shown. Why: … As separate steps: - Click Save. - Check that the page shows "Saved".1 step needs a change: 1 workflow can't run until it is changed.For a routine’s file that a save would make or change, check (and --update, for what it saved) says how many workflows run the routine, and how many it would leave unable to run:
The routine Launch (belay/routines/launch.yaml): 1 workflow runs it, and a save would leave it unable to run.| Code | When |
|---|---|
| 0 | Every file reads and every step is understood. |
| 1 | A step needs a change, so its workflow can’t run until it is changed. |
| 3 | A file cannot be read, or the command could not do its job. |
belay pull
Section titled “belay pull”belay pull --project <project> writes the project’s workflows as files, so a team that wrote its workflows in the app can put them in its repository. --tag, --folder, or --workflow (an id or an exact name) writes only those. Each file goes to <folder>/<file id>.yaml under --out, the folder’s name in lowercase with one - for each run of spaces and other marks, which is belay when left out. With none of --tag, --folder, and --workflow, the project’s routines are written too, each at routines/<file id>.yaml:
Wrote belay/checkout/buy-a-helmet.yamlAlready the same: belay/repairs/book-a-repair.yaml2 workflow files in belay: 1 written, 1 already the same.A file that is already the same, line endings aside, is left as it is. pull never deletes a file. Commit what it writes; a run of those files runs the saved workflows, since they are the same.
On GitHub Actions
Section titled “On GitHub Actions”A pull request’s job:
on: pull_requestjobs: belay: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: belay-qa/run@v1 with: api-key: ${{ secrets.BELAY_API_KEY }} project: Switchback Cycles environment: staging files: belayThe release’s job, with a key that can update workflows:
- uses: actions/checkout@v4 - uses: belay-qa/run@v1 with: api-key: ${{ secrets.BELAY_RELEASE_KEY }} project: Switchback Cycles environment: production files: belay update: truefiles takes one path per line, as the command does, from the repository’s root. The job must check out the repository first, so the files are there.
Exit codes
Section titled “Exit codes”| Code | When |
|---|---|
| 0 | The batch passed: every workflow ran and passed. With --no-wait, the start was accepted. |
| 1 | The batch failed, or it is incomplete: a workflow can’t run, a step was Not found or could not be checked, or a run was cancelled. A single workflow’s run that did not pass. Nothing that was not verified counts as passed. |
| 2 | Interrupted runs are the only trouble, and they remain after the one try to run them again: they were interrupted again, or Belay refused to run them again and the command says why. A single workflow’s run that was interrupted, and belay status --wait on interrupted runs, exit 2 too. |
| 3 | The command could not do its job: a wrong option, a key Belay did not accept, a project, environment, tag, or folder that does not exist, a selection with nothing that can run, a workflow file that cannot be read, a save of files that was refused, a run limit that refused the start, the network, the timeout, or it was stopped. |
belay check has its own codes, above.
Interrupted runs
Section titled “Interrupted runs”Now and then Belay can’t finish a run for a reason of its own. The run is Interrupted: it has no result, your app and your test aren’t the cause, and it doesn’t count against your plan’s runs.
When a batch ends with interrupted runs and nothing else went wrong, the command runs them again once, inside the batch, as Run the interrupted ones again does on the batch’s page, and waits again. The batch’s result then comes from the new runs: 0 if they pass, 1 if one fails. If runs are interrupted again, it says so and exits 2:
One run was interrupted before it could finish, so it has no result. Your app and your test aren’t the cause, and it doesn’t count against your plan’s runs. It was run again once and was interrupted again.
It never runs a failed run again, and interrupted runs beside a failure are not run again, since the job fails either way. A single workflow’s run (--workflow) that is interrupted is not run again; it exits 2.
Stopping and the timeout
Section titled “Stopping and the timeout”- Stopping. Ctrl+C, or a cancelled job, cancels the batch, or with
--workflowthe run: queued runs are cancelled, and a running run finishes the step it is on. The command says so and exits 3. A second Ctrl+C exits at once. - The timeout. When
--timeoutruns out, the command says the batch is still running, prints its link, and exits 3. It does not cancel the batch, which finishes in Belay. - Starting once. If the start fails on the network, Belay answers with a problem on its side, or the key made too many requests, the command tries again with the same request, five times in all with longer waits between, so a retry never starts a second batch. If a read of the batch fails in the same ways, it keeps trying until the timeout; the batch is not affected. Any other refusal ends the command with exit 3.
Other commands
Section titled “Other commands”| Command | Does |
|---|---|
belay status <id> |
Prints a batch (batch-…) or a run (run-…) as it is now. With --wait it follows it to the end and exits by its result, but never cancels or runs anything again. |
belay cancel <id> |
Cancels a batch or a run, and says what it did. |
belay check --project <project> <paths> |
Reads workflow files and says what needs a change, above. |
belay pull --project <project> |
Writes the project’s workflows as files, above. |
belay list projects |
The organization’s projects. |
belay list environments --project <project> |
A project’s environments. |
belay list workflows --project <project> |
A project’s workflows; --tag and --folder narrow it. |
belay list tags --project <project> |
A project’s folders and tags, with how many workflows each holds. |
belay list batches --project <project> |
A project’s recent batches; --environment, --tag, --folder, --result, and --limit narrow it. |
belay list runs |
Recent runs; --project, --workflow, --batch, and --limit narrow it. |
Each takes --json, and belay <command> --help lists its options.
What counts against your plan
Section titled “What counts against your plan”Every run a batch starts counts against your plan’s runs, as a batch started in the app does, a run of a file’s own steps included; a batch starts whole or not at all. belay check and belay pull start no runs. When the plan’s limit has no room for the batch, nothing starts, and the command says which limit and when runs can start again, and exits 3. Interrupted runs don’t count, and the runs that take their place do. See Plan and usage.
A batch started from a pipeline tells nobody: the pipeline is its own notification. Its page says it was started by the key’s name, with “(API)”, and shows the branch, the commit, and the link.
With an agent
Section titled “With an agent”The command is for pipelines. An agent connected over MCP starts and reads batches with start_batch, get_batch, and rerun_interrupted; see Batches. It runs what is saved, not files; get_workflow_files gives it the files to commit beside the code it changed.