-
Notifications
You must be signed in to change notification settings - Fork 101
Editorial pass over environment state docs #3386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,18 @@ | ||
| --- | ||
| layout: src/layouts/Default.astro | ||
| pubDate: 2026-08-07 | ||
| modDate: 2026-08-08 | ||
| modDate: 2026-08-19 | ||
| title: Environment state | ||
| navTitle: Environment state | ||
| description: Save key/value state during a deployment or runbook run, then read it back in later deployments and runs. | ||
| navOrder: 30 | ||
| --- | ||
|
|
||
| Environment state lets a deployment or [runbook](/docs/runbooks) run save key/value pairs scoped to the combination of project, environment, and optionally a tenant. Later deployments and runbook runs for the same project and environment can then read those values back. | ||
| Environment state lets a deployment or [runbook](/docs/runbooks) run store important values generated during the process for later use. Future deployments and runbook runs for the same project, environment, and tenant get access to these state values as variables. | ||
|
|
||
| Environment state is useful in scenarios where a value produced during one run needs to be reused later. A common example is provisioning and deprovisioning [ephemeral environments](/docs/infrastructure/ephemeral-environments). A provisioning runbook might create a Kubernetes namespace or an application URL that later deployments and the deprovisioning runbook depend on. Recording each value as environment state means Octopus stores it once, so every later run reads it directly instead of re-deriving the value. | ||
| A primary use case for environment state is provisioning and deprovisioning [ephemeral environments](/docs/infrastructure/ephemeral-environments). For example, a provisioning runbook creates a Kubernetes namespace for the ephemeral environment deployment. The namespace is stored as an environment state value. When it comes time to deprovision the ephemeral environment, the deprovisioning runbook has the namespace available as a variable to delete it. | ||
|
|
||
| Each state entry is scoped to project, environment, and optionally a tenant, so state isn't shared with other projects, environments, or tenants. Setting an entry with a key that already exists for the same project, environment, and tenant overwrites the previous value. Keys are case insensitive. | ||
| Each state entry is scoped to project, environment, and optionally a tenant, keeping them isolated. Setting an entry with a key that already exists for the same project, environment, and tenant overwrites the previous value. Keys are case insensitive. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Brevity |
||
|
|
||
| ## Setting environment state | ||
|
|
||
|
|
@@ -37,7 +37,7 @@ set_environmentstate "namespace" "webstore-pr-482" | |
|
|
||
| ### Sensitive values | ||
|
|
||
| Mark a value as sensitive to store it encrypted at rest and mask it in task logs. Add the `-Sensitive` switch in PowerShell, or `-sensitive` as the third argument in Bash. | ||
| Mark a value as sensitive to encrypt it at rest and mask it in task logs. Add the `-Sensitive` switch in PowerShell, or `-sensitive` as the third argument in Bash. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Brevity |
||
|
|
||
| <details data-group="set-sensitive-environment-state"> | ||
| <summary>PowerShell</summary> | ||
|
|
@@ -58,9 +58,9 @@ set_environmentstate "connectionString" "Server=db;Password=s3cret" -sensitive | |
|
|
||
| ## Using environment state | ||
|
|
||
| Octopus makes each state entry available as a [variable](/docs/projects/variables) named `Octopus.Environment.State[key]` in later deployment or runbook run, where `key` is the name you set. | ||
| Octopus makes each state entry available as a [variable](/docs/projects/variables) named `Octopus.Environment.State[key]`, where `key` is the key you set. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove repetition. |
||
|
|
||
| Read it from a script: | ||
| To read environment state in a script: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make it a sentence. |
||
|
|
||
| <details data-group="consume-environment-state"> | ||
| <summary>PowerShell</summary> | ||
|
|
@@ -81,7 +81,7 @@ namespace=$(get_octopusvariable "Octopus.Environment.State[namespace]") | |
|
|
||
| ## Setting an environment URL | ||
|
|
||
| An environment URL is a type of environment state, but gets first-class support in Octopus. It is stored like any other environment state, and surfaced as a clickable link in the Octopus Web Portal and available from the API. | ||
| An environment URL is a special type of environment state that gets first-class support in Octopus. It is stored like any other environment state and surfaced as a clickable link in the Octopus Web Portal and available from the API. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm nitpicking here, but there is something confusing to me about leading a sentence with a point of similarity and ending it with two points of difference. Maybe you could separate that sentence into two parts or something?
|
||
|
|
||
| Set a URL with the `Set-EnvironmentUrl` (PowerShell) or `set_environmenturl` (Bash) function. The first argument is the key that names the URL, and the second is the URL itself. | ||
|
|
||
|
|
@@ -102,17 +102,17 @@ set_environmenturl "Store front" "https://pr-123.example.com" | |
|
|
||
| </details> | ||
|
|
||
| URLs set this way show as clickable links on the [Ephemeral Environments](/docs/projects/ephemeral-environments#environment-urls) in the project, so anyone reviewing the environment can open the running app. | ||
| URLs set this way show as clickable links on the [Ephemeral Environments](/docs/projects/ephemeral-environments#environment-urls) in the project, providing convenient access to the deployed application. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarity (what does "reviewing the environment" mean?) |
||
|
|
||
| :::div{.hint} | ||
| A URL is a special kind of environment state, the key used must be unique across all state entries (including other URLs) for the same project, environment, and tenant. Reusing a key overwrites the value stored under it. | ||
| The key used for a URL entry must be unique across all state entries (including non-URLs) for the same project, environment, and tenant. With all state entries, reusing a key will overwrite its value. | ||
| ::: | ||
|
|
||
| ### Getting URLs from the API | ||
|
|
||
| You can fetch the environment URLs from the API, which is useful for AI agents and scripts that need a link to the running app without reading the task log. Add an optional `tenantId` query parameter for [tenanted](/docs/tenants) runs. | ||
| You can fetch the environment URLs from the API, which is useful for AI agents and scripts that need a link to the running app. Add an optional `tenantId` query parameter for [tenanted](/docs/tenants) runs. | ||
|
|
||
| ```text | ||
| ```http | ||
| GET /api/spaces/{spaceId}/projects/{projectId}/environments/{environmentId}/urls | ||
| ``` | ||
|
|
||
|
|
@@ -126,8 +126,9 @@ The response is an array of name and URL pairs: | |
|
|
||
| ## Limits on environment state | ||
|
|
||
| Up to 10 environment state entries can be created for each combination of project, environment and optional tenant. | ||
| Environment state has the following limits: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put this in the list for consistency. |
||
|
|
||
| - Maximum of 10 environment state entries per combination of project, environment, and optional tenant | ||
| - Maximum key length is 100 characters | ||
| - Maximum value length is 1000 characters | ||
|
|
||
|
|
@@ -141,13 +142,13 @@ If a project, environment, and tenant combination has hit the limit above, delet | |
|
|
||
| For environment state scoped to a project and environment: | ||
|
|
||
| ```text | ||
| ```http | ||
| DELETE /api/spaces/{spaceId}/projects/{projectId}/environments/{environmentId}/untenanted/states/{key} | ||
| ``` | ||
|
|
||
| For environment state scoped to a project, environment and tenant: | ||
|
|
||
| ```text | ||
| ```http | ||
| DELETE /api/spaces/{spaceId}/projects/{projectId}/environments/{environmentId}/tenants/{tenantId}/states/{key} | ||
| ``` | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strip out some of the specifics to give an impactful introduction to the feature.