Automate
Command line (CLI)
Install the command line from your server, sign in, use it every day and in a CI pipeline, read its exit codes.
The command line, swarmetry, does in a terminal what you do on screen: list your projects, start a test, wait for
its verdict, read its results. It is one file for your computer, served by your Swarmetry server itself, always in the
version of that server. A CI pipeline uses the same file (see Use it in a CI pipeline).
The command is swarmetry.
Install it
Open Help > Developer access (/app/developer). The page chooses your computer from your browser (Windows, macOS
or Linux, and the processor): change it if you install on another computer. Then follow the steps of the page, or the
same steps below.
In one step (recommended)
On macOS open Terminal (Applications, Utilities), on Linux a terminal, then paste this command and press Enter:
curl --proto '=https' --tlsv1.2 -fsSL https://swarmetry.io/cli/install.sh | sh
On Windows open PowerShell (Start menu, type PowerShell), then paste this command and press Enter:
(Invoke-WebRequest -UseBasicParsing -MaximumRedirection 0 -Uri https://swarmetry.io/cli/install.ps1).Content | Invoke-Expression
The script downloads the file of your computer from your server, checks its SHA-256 against the published checksums, and installs it only if they match. It downloads over https only (TLS 1.2 or later on Linux and macOS; on Windows, the TLS versions of the system) and never follows a redirect to http, and a download cut short by the network runs nothing:
| System | Installed as | Notes |
|---|---|---|
| Linux, macOS | ~/.local/bin/swarmetry |
If the folder is not in your PATH, the script prints the line to add. |
| Windows | %LOCALAPPDATA%\Programs\swarmetry\swarmetry.exe |
The folder is added to your user Path: open a new PowerShell window afterwards. |
Set SWARMETRY_INSTALL_DIR before the command to install into another folder. The Linux and macOS script needs curl
(or GNU Wget): on a system that only has the wget of BusyBox, such as a minimal Alpine Linux, it stops and asks for
curl (apk add curl), because that wget cannot refuse a redirect to an unencrypted address.
Download the file yourself
The page Developer access also lists every file (Windows, macOS and Linux, each for Intel or AMD and for ARM) with its size and SHA-256, and gives the commands that check it. On Linux, for example:
curl --proto '=https' --tlsv1.2 -fLO https://swarmetry.io/cli/files/swarmetry-linux-amd64
echo "<sha256 of the page> swarmetry-linux-amd64" | sha256sum -c -
chmod +x swarmetry-linux-amd64
mkdir -p ~/.local/bin
mv swarmetry-linux-amd64 ~/.local/bin/swarmetry
The check must answer OK (True with the PowerShell commands of the page); otherwise, download again and do not
run the file. SHA256SUMS (link on the page) lists the checksums of every file.
- macOS may refuse to open a file downloaded with a browser, because Apple has not notarized it: open System
Settings > Privacy & Security and choose Open Anyway. Files downloaded with
curl, as above or by the script, are not blocked. - Windows may warn about a file downloaded with a browser, because it is not signed with a certificate: choose More info, then Run anyway, only for a file downloaded from your server. The script avoids the browser.
Checksums and signature
The SHA-256 protects you from a broken download. Once Swarmetry publishes its release key (an OpenSSH key that never
leaves its signing machine), a signature of the checksums with that key (SHA256SUMS.sig) also proves that nobody
changed the files, on the way or on the server itself. Verifying needs ssh-keygen from OpenSSH 8.1 or later (ssh -V prints the version):
it is installed on macOS and on most Linux systems, and on Windows with the OpenSSH client (Settings > System >
Optional features > OpenSSH Client, or Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 in a PowerShell
run as administrator).
Swarmetry's release key
Swarmetry has not published a release key yet: until it does, the files are checked by their SHA-256 only, and a CI pipeline should pin the SHA-256 of its file (see Load tests in a CI pipeline). The key will be published here, on the security page of the Swarmetry website (https://swarmetry.io/en/security) and in the release notes, all three from Swarmetry's source, not from the settings or the files of the server you download from.
The installers and the CI templates are built into the Swarmetry server program, with the release key written in when
that program is built: the server's settings and its download folder cannot change them, only a new release can. Once
a release key is published, they verify the signature by default: they install nothing when the signature is
missing or does not verify, or when ssh-keygen is missing. SWARMETRY_VERIFY_SIGNATURE=0 installs with the SHA-256
check only, and the script says signature not verified; SWARMETRY_VERIFY_SIGNATURE accepts 1 and 0 only, any
other value stops the script.
Before that, or to choose the key yourself (Linux and macOS), ask for the check with SWARMETRY_VERIFY_SIGNATURE=1:
curl --proto '=https' --tlsv1.2 -fsSL https://swarmetry.io/cli/install.sh | SWARMETRY_VERIFY_SIGNATURE=1 sh
The script downloads SHA256SUMS.sig and verifies it with ssh-keygen -Y verify before it trusts SHA256SUMS. It
installs nothing when the signature does not verify, when your server signs nothing, or when ssh-keygen is missing,
and it says checksum and signature verified and with which key when it installs. Without a release key it checks
against the key your server publishes: that proves that the files were not changed on the way or where they are stored,
not that the server itself is the right one. To pin a key yourself, save its line once into a file and give that file
(SWARMETRY_ALLOWED_SIGNERS alone turns the check on; with SWARMETRY_VERIFY_SIGNATURE=0 the script stops):
mkdir -p ~/.config/swarmetry
echo 'swarmetry-cli namespaces="cli.swarmetry.io" ssh-ed25519 AAAA...' > ~/.config/swarmetry/allowed_signers
curl --proto '=https' --tlsv1.2 -fsSL https://swarmetry.io/cli/install.sh | SWARMETRY_VERIFY_SIGNATURE=1 SWARMETRY_ALLOWED_SIGNERS="$HOME/.config/swarmetry/allowed_signers" sh
The line starts with swarmetry-cli (the signer) and namespaces="cli.swarmetry.io": keep them as they are.
On Windows, the PowerShell installer verifies the same way. Set the variables in the same PowerShell window before the install command:
$env:SWARMETRY_VERIFY_SIGNATURE = '1'
(Invoke-WebRequest -UseBasicParsing -MaximumRedirection 0 -Uri https://swarmetry.io/cli/install.ps1).Content | Invoke-Expression
$env:SWARMETRY_ALLOWED_SIGNERS names a file of your own key line, as above.
By hand (Linux; on macOS use shasum -a 256 -c - instead of sha256sum -c -):
curl --proto '=https' --tlsv1.2 -fLO https://swarmetry.io/cli/files/SHA256SUMS
curl --proto '=https' --tlsv1.2 -fLO https://swarmetry.io/cli/files/SHA256SUMS.sig
echo 'swarmetry-cli namespaces="cli.swarmetry.io" ssh-ed25519 AAAA...' > allowed_signers
ssh-keygen -Y verify -f allowed_signers -I swarmetry-cli -n cli.swarmetry.io -s SHA256SUMS.sig < SHA256SUMS
grep ' swarmetry-linux-amd64$' SHA256SUMS | sha256sum -c -
ssh-keygen must answer Good "cli.swarmetry.io" signature for swarmetry-cli with ED25519 key SHA256:..., with the
fingerprint of the release key, and the last line swarmetry-linux-amd64: OK (the downloaded file in the same folder).
Anything else (for example Could not verify signature.): do not run the file. On Windows, the page Developer access
gives the same commands for PowerShell; then compare the SHA-256 of your file with its line of the verified
SHA256SUMS:
(Get-FileHash -Algorithm SHA256 swarmetry.exe).Hash
Select-String 'swarmetry-windows-amd64.exe' SHA256SUMS
Check that it works
swarmetry --version # the version of the command line, for example: swarmetry version v3.0.0
swarmetry version # once signed in: the versions of the command line and of the server
Sign in
-
Create an API token in Account > API tokens (
/app/settings/tokens) and copy it: it is shown once (see API tokens). -
Run this command, paste the token on the empty line that follows and press Enter:
swarmetry login --token-stdinThe token is not part of the command, so it never stays in your terminal history. The answer says who you are signed in as and in which organization.
Where the token is kept
swarmetry login keeps the token in the keychain of your computer: the Keychain on macOS (entry swarmetry-cli),
the Credential Manager on Windows, and on Linux the keyring of your desktop (GNOME Keyring, KWallet). It writes the
address of your server and a reference to that entry in swarmetry/config.json under your user configuration folder
(~/.config on Linux, ~/Library/Application Support on macOS, %AppData% on Windows), readable by you only: the
token itself is not in that file.
When the keychain cannot be reached, sign in with --insecure-storage or give the token with SWARMETRY_TOKEN
instead. That is the case when the command runs:
- on another computer that shares your home folder (a network home folder): the file is there, the keychain entry is on the first computer only;
- from a scheduled job (
cron, a scheduled task) after you have signed out of your desktop session: the keyring is locked or gone; - from an AI assistant installed as a sandboxed application (Flatpak, Snap): the sandbox may not reach your keyring, so
set
SWARMETRY_TOKENin the assistant's settings for the command line; - on a server without a desktop, in a container or on a CI runner: there is no keychain at all (see below).
In detail:
- No keychain, or one that does not answer within 10 seconds (for example a locked keyring nobody can unlock): the
token is written in the file, readable by you only, and
loginsays so in one line starting withNotice:. If an entry may stay in the keychain (a keychain that answers too late, or the token of your previous sign-in), that line names it so that you can delete it. - To keep the token in the file anyway, add
--insecure-storage:swarmetry login --token-stdin --insecure-storage. Anyone who can read your files can then read the token. - A file from an earlier version of the command line, with the token inside, keeps working. Run
swarmetry loginalone: it checks that token again and moves it to the keychain. - The saved token belongs to its server. It is sent only to the server you signed in to. To use another server
with the same configuration, sign in to it, or give its token with
SWARMETRY_TOKENtogether withSWARMETRY_URL. - The file must stay private. On Linux and macOS the command line refuses a saved token when other users can read
or change the configuration file, and refuses any token when other users can change the server address in it; it
gives the command that fixes it:
chmod 600 "<the file>". On Windows Subsystem for Linux, a file under/mnt/cshows as readable by everyone and is refused: keep the configuration in your Linux home folder (the default). - The variable
SWARMETRY_TOKENreplaces the saved token (a CI pipeline uses it): the keychain is then not used.SWARMETRY_CONFIGnames another configuration file. swarmetry logoutdeletes the token from the keychain and the configuration file; revoke the token on the tokens page, as it stays valid until then.
Give the token with --token-stdin or SWARMETRY_TOKEN, never in the command itself: other programs of your computer
can see the arguments of a command, and your shell history keeps them. An older form, --token <token>, still works
but prints a warning on the error output each time: a pipeline that fails when a command writes to its error output
fails there too, so use SWARMETRY_TOKEN.
Everyday commands
swarmetry project list
swarmetry run start --project-id <id> --scenario-id <id> -y
swarmetry run wait --project-id <id> --run-id <id>
swarmetry --help # every operation is a command: <domain> <verb>
swarmetry run start --help # the flags of one command
- Flags come from the fields of the operation (
--project-id); complex inputs use--input-jsonor--input-file. -o jsonprints the raw answer, for scripts.- Costly and destructive commands ask
Continue? [y/N]. Without a terminal (a script, a pipeline) they need-y, which means you confirm them. - The commands follow your role, the scopes of your token and your plan, exactly as the web app: a refusal says why,
and for the refusals of a test start a
hint:line says what to do.
Send a file: imports and datasets
swarmetry upload <file> sends a file to your server and prints its upload id (-o json prints the upload as JSON).
Give that id once, within 24 hours, to the command that reads the file; only you can use it. Or give the file to that
command with --file, which uploads it first:
swarmetry upload users.csv # prints the upload: id, file name, size, expiry
swarmetry dataset create --project-id <id> --name Users --upload-id <upload id>
swarmetry scenario import --project-id <id> --file recording.har
Without an upload, these commands only take a small content in the command itself (--content). The server limits the
size of an upload: a file too large is refused with upload.too_large and the largest size allowed. --filename sets
the name the platform keeps, --content-type the type of the file (by default from its extension).
Download a report
swarmetry report download --project-id <id> --report-id <id> # the PDF, under the name the server gives
swarmetry report download --project-id <id> --report-id <id> --format html --file report.html
--format is pdf (default), html, json, csv (with --table), junit, markdown or zip; --file - writes
the file to the standard output. The file is complete or absent: a download cut short leaves nothing behind.
Use it in a CI pipeline
swarmetry run start … -y --wait starts a test and waits for its verdict; swarmetry run wait waits for a test that
is already running. Both print a short summary (verdict, failed thresholds, links to the run) and exit with the code of
the verdict below, so the pipeline fails when the test fails. Useful flags:
| Flag | Effect |
|---|---|
--junit <file> |
Writes the JUnit XML of the ended run (verdict, thresholds, checks), also when it fails |
--summary-json <file> |
Writes the summary as JSON |
--timeout <duration> |
Longest wait (default 6h); --stop-on-timeout stops the run then |
--allow-no-verdict |
A run without thresholds exits 0 instead of 22 |
--report |
Also generates a report of the run (uses one report of your plan) |
--report-file <file> |
Generates the report and saves it to this file, to keep it with the build (implies --report); --report-format chooses pdf (default), html, json, csv, junit, markdown or zip |
--preflight-if-required |
run start only: when the run policy of your organization requires a passed preflight, runs it first, waits for its result and starts the test with it (see below) |
Preflight required. When your organization requires a passed preflight before large tests (Administration > Approvals,
see chapter 21), a start without one is refused with run.preflight_required (exit 6). With
--preflight-if-required the command runs that preflight (a short real run with a few virtual users: it is costly too,
and -y confirms it as well), waits for its result and starts the test with it. A preflight that does not pass prints
what it found and exits 26: the test is not started. swarmetry run wait on a preflight exits 0 when it passed, 26
otherwise.
Your server gives ready files for GitHub Actions, GitLab CI/CD and any other CI: see Load tests in a CI pipeline.
In a pipeline, set SWARMETRY_URL and SWARMETRY_TOKEN (a secret of the pipeline) instead of swarmetry login.
Quota and plan refusals exit 8 and 4: do not retry them in a loop. If your organization limits the addresses allowed
to call the API, add the addresses of your CI runners.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Done (for a wait: the test passed) |
| 1 | Unexpected error |
| 2 | Invalid command line or input file |
| 3 | Not signed in, or the token was refused or expired |
| 4 | Forbidden: permission, token scope or plan feature |
| 5 | Not found |
| 6 | Conflict, an approval is required, or a passed preflight is required (--preflight-if-required) |
| 7 | Invalid input |
| 8 | Quota exceeded or too many requests |
| 9 | Server error |
| 10 | Not confirmed (a costly or destructive command without -y) |
| 11 | Server unreachable |
| 20 | The test failed: a threshold failed, the test was stopped by a threshold, or its script marked it failed |
| 21 | Inconclusive: nothing failed, but the test cannot be declared passed |
| 22 | Finished without a verdict: the test has no threshold |
| 23 | Stopped before its end, for another reason than a threshold |
| 24 | Technical failure of the test |
| 25 | --timeout reached while the test was still running |
| 26 | The preflight did not pass (failed or incomplete): with --preflight-if-required, the test was not started |
| 130 | Interrupted (Ctrl+C, or the pipeline was cancelled) |
When the server is newer
The command line knows the operations of its own version. When your server runs a newer version, login, version
and the waits print one line, for example The server runs v3.1.0 and this CLI is v3.0.0: download the matching CLI from https://swarmetry.io/app/developer. Install again from Developer access: the files there are always
the version of your server. The notice never changes an exit code; SWARMETRY_NO_VERSION_CHECK=1 turns it off. The
command line never downloads or replaces itself.
AI assistants without a remote connection
Clients that only start local servers can use swarmetry mcp --stdio, which forwards to your server with your
sign-in. See Connect an MCP client, step by step for each client. Add --tools runs,scenarios to choose the tool groups it lists, or --tools all for every tool.