Skip to content

Commit

Permalink
enhance(reference/env): add missing keys and callout escaped keys
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Oct 14, 2024
1 parent 1b8257c commit a152e80
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
2 changes: 2 additions & 0 deletions content/reference/environment/substitution.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ If you want to play with the examples above in a terminal, make sure you are in
var expressions are evaluated before the yaml is parsed. If you do not want the system to evaluate an expression it must be escaped.
{{% /alert %}}

This can come in handy particularly when dealing with [runtime build environment variables](/docs/reference/environment/variables/#using-substitution-for-platform-variables).

```diff
version: "1"
steps:
Expand Down
56 changes: 41 additions & 15 deletions content/reference/environment/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,35 @@ The following table includes variables only available during the **tag** event.
| ---------------- | -------- | ------------------------------------------ |
| `VELA_BUILD_TAG` | `v1.0.0` | tag is populated from the source reference |

##### OpenID Connect only

{{% alert color="info" %}}
The following table includes variables only available when the step `id_request` field has a value.
{{% /alert %}}

| Key | Value | Explanation |
| ------------------------------ | ----------------------------------------------------------------------- | ------------------------------------- |
| `VELA_ID_TOKEN_REQUEST_URL` | `<VELA_SERVER_ADDR>/api/v1/repos/<ORG>/<REPO>/builds/<BUILD>/id_token` | URL to request an ID token |
| `VELA_ID_TOKEN_REQUEST_TOKEN` | `ey123abc...` | bearer token for requesting ID token |


#### Vela Environment Variables

| Key | Value | Explanation |
| ---------------- |---------------------------------------------------|---------------------------------------------------------------------|
| `VELA` | `true` | environment is Vela |
| `VELA_ADDR` | `vela.example.com` | fully qualified domain name of the Vela server |
| `VELA_CHANNEL` | `vela` | queue channel the build was published to |
| `VELA_DATABASE` | `postgres` | database Vela is connected to |
| `VELA_HOST` | `vela-worker-1` | fully qualified domain name of the worker the build was executed on |
| `VELA_QUEUE` | `redis` | queue build was published to |
| `VELA_RUNTIME` | `docker` | runtime environment build was executed in |
| `VELA_SOURCE` | `github` | queue channel the build was published to |
| `VELA_VERSION` | `v0.1.0` | Vela version |
| `VELA_WORKSPACE` | `/vela/src/github.com/github/octocat/hello-world` | working directory the build is executed in |
| `CI` | `true` | Indicates this is a CI environment |
| Key | Value | Explanation |
| ---------------------- |---------------------------------------------------|---------------------------------------------------------------------|
| `VELA` | `true` | environment is Vela |
| `VELA_ADDR` | `vela.example.com` | fully qualified domain name of the Vela server |
| `VELA_CHANNEL` | `vela` | queue channel the build was published to |
| `VELA_DATABASE` | `postgres` | database Vela is connected to |
| `VELA_HOST` | `vela-worker-1` | fully qualified domain name of the worker the build was executed on |
| `VELA_QUEUE` | `redis` | queue build was published to |
| `VELA_RUNTIME` | `docker` | runtime environment build was executed in |
| `VELA_SOURCE` | `github` | queue channel the build was published to |
| `VELA_VERSION` | `v0.1.0` | Vela version |
| `VELA_WORKSPACE` | `/vela/src/github.com/github/octocat/hello-world` | working directory the build is executed in |
| `CI` | `true` | Indicates this is a CI environment |
| `VELA_OUTPUTS` | `/vela/outputs/.env` | file path for dynamic environment |
| `VELA_MASKED_OUTPUTS` | `/vela/outputs/masked.env` | file path for dynamic environment for sensitive values |

#### Repository Environment Variables

Expand Down Expand Up @@ -136,8 +149,6 @@ The following table includes variables only available during the **tag** event.
| Key | Value | Explanation |
| ---------------------- | --------------------------- | ---------------------------------- |
| `VELA_USER_ACTIVE` | `true` | active setting for the user |
| `VELA_USER_ADMIN` | `true` | admin platform status for the user |
| `VELA_USER_FAVORITES` | `[ "octocat/hello-world" ]` | favorites starred for the user |
| `VELA_USER_NAME` | `Octocat` | user handle setting for the user |

## Step Only Defaults
Expand Down Expand Up @@ -175,3 +186,18 @@ The following environment variables are **only** injected into every step contai
| `VELA_SERVICE_RUNTIME` | `docker` | runtime where the service was executed |
| `VELA_SERVICE_STARTED` | `1556730001` | unix timestamp representing service start time |
| `VELA_SERVICE_STATUS` | `success` | status of the service |

## Using Substitution For Platform Variables

There are a few default environment variables that need to be [escaped](/docs/reference/environment/substitution/#escaping) when attempting to substitute, as they are not available or not accurate at compile time.

| Key | Compile Time | Build Time Example |
| -------------------------- | ------------- | ------------------- |
| `VELA_BUILD_STARTED` | `0` | `1556730001` |
| `VELA_BUILD_STATUS` | `pending` | `running` |
| `VELA_BUILD_APPROVED_AT` | `0` | `1556730001` |
| `VELA_BUILD_APPROVED_BY` | `''` | `Octocat` |
| `VELA_BUILD_ENQUEUED` | `0` | `1556730001` |
| `VELA_BUILD_RUNTIME` | `''` | `docker` |
| `VELA_BUILD_DISTRIBUTION` | `''` | `linux` |
| `VELA_BUILD_HOST` | `''` | `vela-worker-42` |

0 comments on commit a152e80

Please sign in to comment.