qc env vars
Manage the environment variables of one Quant Cloud environment. The qc env vars commands need @quantcdn/quant-cloud-cli 0.7.0 or later. To upgrade, run npm install -g @quantcdn/quant-cloud-cli.
Subcommands
Section titled “Subcommands”| Command | Description |
|---|---|
qc env vars list |
List the variables of an environment. Values are hidden unless you pass --show-values. |
qc env vars get |
Print the value of one variable. |
qc env vars set |
Set one variable, or every variable in a .env file. |
qc env vars unset |
Remove a variable. |
Every subcommand takes the context flags:
| Flag | Description |
|---|---|
--org <org> |
Organization machine name. Overrides .quant.yml and the active organization. |
--app <app> |
Application machine name. Overrides .quant.yml and the active application. |
--env <env> |
Environment name. Overrides .quant.yml and the active environment. |
If no organization, application or environment can be found, the command stops with a message such as No environment specified. Use --env or set active environment.
These commands manage plain environment variables. Store passwords and keys as secrets in the dashboard (Environment & Secrets).
qc env vars list
Section titled “qc env vars list”List the variables of an environment, sorted by name.
Synopsis
Section titled “Synopsis”qc env vars list [--json] [--show-values] [--org <org>] [--app <app>] [--env <env>]Options
Section titled “Options”| Flag | Description |
|---|---|
--json |
Print the variables as a JSON array of { "name", "value" } objects. |
--show-values |
Print the values. Without this flag every value shows as ********, so a list in a CI log does not expose values. |
Example
Section titled “Example”qc env vars list --env stagingqc env vars list --env staging --json --show-valuesqc env vars get
Section titled “qc env vars get”Print the value of one variable, and nothing else. Use it in scripts:
DEBUG_VALUE="$(qc env vars get APP_DEBUG --env staging)"Synopsis
Section titled “Synopsis”qc env vars get <key> [--org <org>] [--app <app>] [--env <env>]If the variable is not set, the command prints Variable '<key>' is not set on <org>/<app>/<env>. and exits with status 1. On a terminal, control characters are removed from the value before it is printed.
qc env vars set
Section titled “qc env vars set”Set one variable, or every variable in a .env file.
Synopsis
Section titled “Synopsis”qc env vars set <key> <value> [--org <org>] [--app <app>] [--env <env>]qc env vars set <key> --stdin [--org <org>] [--app <app>] [--env <env>]qc env vars set --file <path> [--org <org>] [--app <app>] [--env <env>]Options
Section titled “Options”| Flag | Description |
|---|---|
--stdin |
Read the value from standard input. The value is then not in the process arguments or the shell history. One trailing newline is removed. |
--file <path> |
Set each variable in a .env file. Variables that are not in the file are kept. |
- A variable name starts with a letter or
_, followed by letters, digits,_,.or-. - A value cannot be empty. To remove a variable, use
qc env vars unset. - Give a value as an argument or with
--stdin, not both.--filecannot be combined with a key, a value or--stdin. --filereadsKEY=VALUElines (an optionalexportprefix, quoted values and#comments are allowed). The command refuses the whole file, before any change, if a line is not aKEY=VALUEline, uses theKEY: VALUEform, has an invalid name or an unclosed quote, or repeats a key.- Each variable is saved on its own. If some variables fail, the others are still saved, the command lists the failures and exits with status 1.
Examples
Section titled “Examples”# One plain valueqc env vars set APP_DEBUG false --env staging
# A value from a CI variable, kept off the command lineprintf '%s' "$API_TOKEN" | qc env vars set API_TOKEN --stdin --env production
# Every variable in a fileqc env vars set --file .env.production --env production
# Apply the changesqc env state redeploy --env productionqc env vars unset
Section titled “qc env vars unset”Remove a variable.
Synopsis
Section titled “Synopsis”qc env vars unset <key> [-y] [--org <org>] [--app <app>] [--env <env>]Options
Section titled “Options”| Flag | Description |
|---|---|
-y, --yes |
Do not ask for confirmation. |
On a terminal, the command asks before it removes the variable. In scripts and CI (no terminal) it does not ask. If the variable is not set, the command says so and changes nothing.
Errors
Section titled “Errors”| Message | Cause |
|---|---|
Not authenticated. Run qc login to authenticate. |
No login for the active platform. |
Authentication expired. Run qc login to re-authenticate. |
HTTP 401. |
Access denied. Changing variables needs the write_environments permission. |
HTTP 403. |
Environment not found. Check --org, --app and --env. |
HTTP 404. |
qc env vars is not a command |
The CLI is older than 0.7.0. Upgrade it. |
See also
Section titled “See also”qc env: environments, logs and state, includingqc env state redeploy.- Environment Vars Action: set variables from a GitHub workflow.
