Out Plane
env

env set

Set environment variables.

writesrepeatable--dry-run

Adds variables, or replaces the ones that already exist. Only the keys you name are touched, so nothing you did not mention can be lost.

Saving is not deploying. Without --deploy the running application keeps the values it started with, and this is the easiest thing here to get wrong.

--hangar <name> sets them on a Hangar instead, which picks them up the next time it starts. --restart restarts it in the same command, ending whatever runs in its terminal.

Usage

outplane env set <ASSIGNMENT...> [flags]

Arguments

ArgumentTypeDescription
ASSIGNMENTstringKEY=VALUE, repeatable. Required. Takes the rest of the line.

Flags

FlagTypeDescription
--appstringApplication name or id. Defaults to the linked app. A flag rather than an argument, so that variable names cannot be mistaken for it.
--hangarstringA Hangar's name or id, instead of an application. Not with --app.
--deployboolDeploy afterwards, so the change reaches the running app. Not with --hangar.
--restartboolWith --hangar: restart the Hangar afterwards, so the change reaches it now. Stops everything running in its terminal. Restarts nothing on a paused Hangar.

The global flags apply as well.

Output

FieldTypeDescription
actionstringOne of set, unset.
keysarrayThe names that were written, sorted.
appstring
changedboolFalse for a dry run.
deploymentIdint | nullThe deployment --deploy started, or null when it was not given.
restartedbool | nullWhether --restart restarted the Hangar. false without it, on a paused Hangar, for a dry run and when the restart was refused. null when the target is an application.

Examples

Set one variable on the linked app

outplane env set LOG_LEVEL=debug

Set several and apply them at once

outplane env set LOG_LEVEL=debug TIMEOUT=30 --app checkout --deploy

See what would happen

outplane env set LOG_LEVEL=debug --dry-run

Give an application a managed database's connection string

outplane env set DATABASE_URL="$(outplane db url orders)" --app checkout --deploy

Set one and read what changed

outplane env set LOG_LEVEL=debug --json --fields keys,changed
{
  "changed": true,
  "keys": [
    "LOG_LEVEL"
  ]
}

Set one on a Hangar and restart it to apply it now

outplane env set LOG_LEVEL=debug --hangar myhangar --restart --json --fields app,changed,restarted
{
  "app": "myhangar",
  "changed": true,
  "restarted": true
}

What to Know

  • Saving does not restart anything. Without --deploy the running application keeps the values it started with, which is the single easiest thing to get wrong here.
  • Only the named keys are changed. This command never sends the whole set, so it cannot drop a variable it was not told about.
  • A value may contain an equals sign: only the first one separates the key, so KEY=a=b sets KEY to a=b.
  • HOSTNAME and any key starting with OP_, KUBERNETES_ or HANGAR_ are refused. PORT is not reserved and may be set.
  • Setting an existing key replaces it, so running this twice with the same arguments leaves the same state.
  • deploymentId is null unless --deploy was given. A queued deployment is not a finished one; follow it with outplane deploy logs.
  • --hangar names a Hangar instead of an application, and is refused together with --app. A Hangar is an application record with the same id, so the requests are the same, and a result's app field holds the Hangar's name.
  • Saving changes nothing running in a Hangar either. It is started from its saved variables, groups and ports, so without --restart a change applies at its next outplane hangar restart, or at outplane hangar resume when it is paused. --restart is refused without --hangar, and --deploy with it.
  • --restart stops everything running in the Hangar's terminal, agents included, and disconnects anyone connected; files under /home/hangar stay. An agent working inside the Hangar ends its own session by passing it. On a paused Hangar it restarts nothing and does not fail, and a restart the server refuses still exits 0 once the change is saved, with restarted false and the reason on stderr.

Errors

Beyond 0 for success, this command exits with:

ExitKindMeaning
2usageInvalid arguments, unknown flag, or client-side validation failure.
3authNot authenticated, token revoked or expired, or forbidden for this team.
5not_foundThe named resource does not exist, or is not visible to this credential.
8upstreamThe Out Plane API returned a server error.

The code on the error object is one of usage.bad_assignment, usage.duplicate_key, env.reserved_key, env.reserved_prefix, env.key_too_long, env.value_too_long, env.too_many, context.no_app, app.not_found, hangar.not_found, hangar.ambiguous, usage.conflicting_flags, usage.empty_argument. Branch on that, or on the exit status. The message is prose and changes.

On this page