Command reference
Every command, subcommand and flag the semaphore binary accepts, in the order
semaphore help walks the tree. Use it to confirm a flag name or a default; the
pages next to it explain what the commands are for.
Every command reads the same configuration as the server, so point it at the right
configuration file with --config when you run more than one instance on a host.
See CLI for the lookup order.
Global flags
These are accepted by every command.
| Flag | Type | Default | Description |
|---|---|---|---|
--config | string | — | Configuration file path |
--debug-filter | string | — | Debug namespace filter (only with DEBUG level), e.g. 'runner,task_' or ',-db' |
--log-level | string | — | Log level: DEBUG, INFO, WARN, ERROR, FATAL, PANIC |
--no-config | bool | — | Don't use configuration file |
semaphore client
Manage a Semaphore UI server from the terminal or from scripts over its REST API. The client needs a server URL and an API token. Give them with flags, with SEMAPHORE_CLIENT_* environment variables, or save them once as a named context with 'semaphore client auth login' (stored in ~/.semaphore/client.yml with mode 0600). Precedence: flag > environment > context > default. Commands follow the form 'semaphore client <resource> <action> [id|name]'. Results go to stdout as a table, JSON (-o json) or YAML (-o yaml); messages and errors go to stderr. Exit codes: 0 success, 1 client or API error, 2 usage error, 3 the awaited task failed, 4 authentication failed, 5 not found, 6 the awaited task was stopped, 124 wait timeout, 130 interrupted.
semaphore client
Example:
# Save a server and its token as the current context
echo "$TOKEN" | semaphore client auth login --url https://semaphore.example.com --with-token
# List templates of project 1 as JSON
semaphore client template list -p 1 -o json
# Run a template and follow its log; exit code tells how the task ended
semaphore client template run deploy -p 1 --follow
| Flag | Type | Default | Description |
|---|---|---|---|
--ca-cert | string | — | PEM file with the CA that signed the server certificate ($SEMAPHORE_CLIENT_CA_CERT) |
--context | string | — | Named context from the configuration file ($SEMAPHORE_CLIENT_CONTEXT) |
--debug | bool | — | Trace HTTP requests to stderr with secrets masked ($SEMAPHORE_CLIENT_DEBUG) |
--fields | stringSlice | — | Fields to show, comma-separated JSON field names (e.g. id,name,status) |
--insecure | bool | — | Skip TLS certificate verification ($SEMAPHORE_CLIENT_INSECURE) |
--no-color | bool | — | Disable colors (also $NO_COLOR) |
--no-headers | bool | — | Omit the table header line |
--no-input | bool | — | Never prompt; fail instead ($SEMAPHORE_CLIENT_NO_INPUT, $CI) |
--output, -o | string | — | Output format: table, json or yaml ($SEMAPHORE_CLIENT_OUTPUT, default table) |
--project, -p | string | — | Project id or name for project-scoped commands ($SEMAPHORE_CLIENT_PROJECT) |
--quiet, -q | bool | — | Print only ids, one per line |
--timeout | duration | 0s | HTTP request timeout, e.g. 30s ($SEMAPHORE_CLIENT_TIMEOUT, default 30s) |
--url | string | — | Server URL, e.g. https://semaphore.example.com ($SEMAPHORE_CLIENT_URL) |
--yes, -y | bool | — | Answer yes to confirmations |
| Subcommand | Purpose |
|---|---|
semaphore client auth | Log in to a server and manage the saved token |
semaphore client context | Manage saved servers (contexts) |
semaphore client environment | Manage variable groups (environments) |
semaphore client info | Show the server version and settings |
semaphore client inventory | Manage inventories |
semaphore client key | Manage access keys (SSH keys, passwords) |
semaphore client project | Manage projects |
semaphore client repository | Manage repositories |
semaphore client runner | Manage runners (global, or a project's with --project) |
semaphore client schedule | Manage schedules (cron runs of templates) |
semaphore client task | Inspect, follow, stop and rerun tasks |
semaphore client template | Manage task templates |
semaphore client user | Manage users of the server (administrators only) |
semaphore client view | Manage views (template groups on the project page) |
semaphore client auth
Log in to a Semaphore server and save the server URL and an API token as a named context in ~/.semaphore/client.yml (mode 0600). Later commands use the current context unless --url, --context or SEMAPHORE_CLIENT_* say otherwise.
semaphore client auth
Example:
semaphore client auth login --url https://semaphore.example.com
echo "$TOKEN" | semaphore client auth login --url https://semaphore.example.com --with-token
semaphore client auth status
| Subcommand | Purpose |
|---|---|
semaphore client auth login | Save a server and an API token as a context |
semaphore client auth logout | Forget the token of the current context |
semaphore client auth status | Show which server and token are in use and whether they work |
semaphore client auth token | Print the API token in use |
semaphore client auth login
Save a server and an API token as a context and make it the current one. Two ways to authenticate: * Paste a token: with --with-token, or whenever stdin is not a terminal, the first line of stdin is read as an existing API token and checked against the server. Create one in the web UI under Settings > API tokens. * Log in with a password: in an interactive terminal the command asks for the login and the password (and a one-time code when two-factor authentication is enabled), creates an API token named --name with lifetime --ttl, and closes the web session. The password is never stored. The context is named by --context, or after the server host. The token is written to the configuration file with mode 0600; use --ca-cert or --insecure to describe a server with a private certificate and they are saved as well.
semaphore client auth login [flags]
Example:
# Paste an existing token (CI, scripts)
echo "$SEMAPHORE_TOKEN" | semaphore client auth login --url https://semaphore.example.com --with-token
# Interactive login with a password, token valid for 30 days
semaphore client auth login --url https://semaphore.example.com --ttl 720h
# Save a second server under its own name
semaphore client auth login --url https://staging.example.com --context staging
| Flag | Type | Default | Description |
|---|---|---|---|
--login | string | — | Login or e-mail for the password flow (asked when omitted) |
--name | string | — | Name of the API token to create (default semaphore-cli@<hostname>) |
--ttl | duration | 0s | Lifetime of the created token, e.g. 720h (default: never expires) |
--with-token | bool | — | Read an existing API token from the first line of stdin |
semaphore client auth logout
Remove the token from the current context in the configuration file. With --revoke the token is also deleted on the server, so it stops working everywhere. The context itself (URL, project, TLS settings) stays; delete it with 'semaphore client context delete'.
semaphore client auth logout [flags]
Example:
semaphore client auth logout
semaphore client auth logout --context staging --revoke
| Flag | Type | Default | Description |
|---|---|---|---|
--revoke | bool | — | Also delete the token on the server |
semaphore client auth status
Show the current context, the server URL, where the token comes from (flag, environment, context file) and the user the token belongs to. Exit code 4 means the server rejected the token.
semaphore client auth status
Example:
semaphore client auth status
semaphore client auth status --context staging -o json
semaphore client auth token
Print the API token the client would send, for handing it to another tool: curl -H "Authorization: Bearer $(semaphore client auth token)" ... The token is written to stdout only; a warning goes to stderr when stdout is a terminal, because a token on screen tends to end up in screenshots and logs.
semaphore client auth token
Example:
curl -H "Authorization: Bearer $(semaphore client auth token)" https://semaphore.example.com/api/user
semaphore client context
Manage the contexts saved in ~/.semaphore/client.yml. A context is a server URL with its token, an optional default project and TLS settings. One context is current; --context or SEMAPHORE_CLIENT_CONTEXT selects another one per call.
semaphore client context
Aliases: contexts, ctx.
Example:
semaphore client context list
semaphore client context use staging
semaphore client context set prod --url https://semaphore.example.com --project 3
| Subcommand | Purpose |
|---|---|
semaphore client context delete | Delete a context |
semaphore client context get | Show one context (the current one by default) |
semaphore client context list | List saved contexts |
semaphore client context set | Create or change a context without logging in |
semaphore client context use | Make a context the current one |
semaphore client context delete
Remove a context from the configuration file. The token stored in it is forgotten but not revoked on the server; use 'auth logout --revoke' for that. Asks for confirmation in a terminal; pass --yes to skip it.
semaphore client context delete NAME
Aliases: rm.
Example:
semaphore client context delete staging -y
semaphore client context get
Show one saved context without its token. Without a name the current context is shown.
semaphore client context get [NAME]