# Live contexts

This page describes the contexts a [live workflow](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax/..#live-workflow) can use in expressions for calculating YAML attribute values.

## Live Contexts

| Context name | Description                                                                                                          |
| ------------ | -------------------------------------------------------------------------------------------------------------------- |
| `env`        | Contains environment variables set in a workflow or a job. For more information, see [`env` context](#env-context) . |
| `flow`       | Information about the main workflow settings, defaults, etc. See [`flow` context](#flow-context) for details.        |
| `project`    | Information about the project. See [`project` context](#project-context) for details.                                |
| `images`     | Contains a mapping of images on the Apolo registry. See [`images` context](#images-context) for details.             |
| `multi`      | Multi-job context. For more information, see [`multi` context](#multi-context).                                      |
| `params`     | A mapping of global workflow parameters. For more information, see [`params` context](#params-context).              |
| `tags`       | A set of job tags set in a workflow or a job. See [`tags` context](#tags-context) for details.                       |
| `volumes`    | Contains a mapping of volume definitions. For more information, see [`volumes` context](#volumes-context).           |
| `git`        | A mapping of the flow's workspace to a git repository. For more information, see [`git` context](#git-context).      |

### `env` context

The `env` context contains environment variables that have been set in a workflow or a job. For more information about setting environment variables in your workflow, see "[Live workflow syntax](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax/..#live-workflow)."

The `env` context syntax allows you to use the value of an environment variable in your workflow file. If you want to use the value of an environment variable inside a job, use your operating system's standard method for reading environment variables.

| Property name    | Type  | Description                                   |
| ---------------- | ----- | --------------------------------------------- |
| `env.<env-name>` | `str` | The value of a specific environment variable. |

### `flow` context

The `flow` context contains information about the workflow: its id, title, etc.

| Property name     | Type        | Description                                                                                                                                                                                                                                                                                                                                                               |
| ----------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `flow.flow_id`    | `str`       | The workflow's ID. It's automatically generated based on the workflow's YAML filename with a dropped suffix (this will always `'live'` in live mode). You can override the property by setting the [`flow.id`](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax/..#id) attribute.                                                    |
| `flow.project_id` | `str`       | The project's ID. It is automatically generated based on the name of the flow folder. You can override it using [`project.id`](https://docs.apolo.us/index/apolo-flow-reference/project-configuration-syntax#id) attribute. Check [the project configuration](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/project-configuration-syntax) for details. |
| `flow.workspace`  | `LocalPath` | A path to the workspace (the root folder of the flow).                                                                                                                                                                                                                                                                                                                    |
| `flow.title`      | `str`       | The workflow title. Set the [`flow.title`](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax/..#title) attribute to override the auto-generated value.                                                                                                                                                                                |
| `flow.username`   | `str`       | Name of user who executed the workflow run.                                                                                                                                                                                                                                                                                                                               |

### `project` context

The `project`context contains information about the project: its ID, owner, etc.

| Property name          | Type  | Description                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ---------------------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `project.id`           | `str` | The project's ID. It is automatically generated based on the name of the flow folder. You can override it using [`project.id`](https://docs.apolo.us/index/apolo-flow-reference/project-configuration-syntax#id) attribute. Check [the project configuration](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/project-configuration-syntax) for details. This context property is an alias to `flow.project_id` . |
| `project.owner`        | `str` | The project's owner. See also: [the project configuration](https://docs.apolo.us/index/apolo-flow-reference/project-configuration-syntax#owner).                                                                                                                                                                                                                                                                                   |
| `project.project_name` | `str` | The platform project name. Set the [project.project\_name](https://docs.apolo.us/index/apolo-flow-reference/project-configuration-syntax#project_name) attribute to override the auto-calculated value.                                                                                                                                                                                                                            |

### `images` context

Contains information about images defined in the [`images` section](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax/..#images) of a *live* workflow.

| Property name                            | Type                  | Description                                                                                                                                                                                                                                                                                                                                  |
| ---------------------------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `images.<image-id>.id`                   | `str`                 | The image definition identifier. For more information, see [`images.<image-id>`](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax/..#images-less-than-image-id-greater-than) section.                                                                                                                   |
| `images.<image-id>.ref`                  | `str`                 | The image reference. For more information, see [`images.<image-id>.ref`](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax/..#images-less-than-image-id-greater-than-ref) attribute.                                                                                                                     |
| `images.<image-id>.context`              | `LocalPath` or `None` | <p>The context directory used for building the image or <code>None</code> if the context is not set. The path is relative to the flow's root (<code>flow\.workspace</code> property).</p><p>For more information, see <a href="..#images-less-than-image-id-greater-than-context"><code>images.\<image-id>.context</code> attribute</a>.</p> |
| `images.<image-id>.full_context_path`    | `LocalPath` or `None` | The absolute path, pointing to the `context` folder if set.                                                                                                                                                                                                                                                                                  |
| `images.<image-id>.dockerfile`           | `LocalPath`or `None`  | <p>A path to <code>Dockerfile</code> or <code>None</code> if not set.</p><p>For more information, see <a href="..#images-less-than-image-id-greater-than-dockerfile"><code>images.\<image-id>.dockerfile</code> attribute</a>.</p>                                                                                                           |
| `images.<image-id>.full_dockerfile_path` | `LocalPath` or `None` | Full version of the `dockerfile` attribute.                                                                                                                                                                                                                                                                                                  |
| `images.<image-id>.build_args`           | `list[str]`           | <p>A sequence of additional build arguments.</p><p>For more information, see <a href="..#images-less-than-image-id-greater-than-build_args"><code>images.\<image-id>.build\_args</code> attribute</a>.</p>                                                                                                                                   |
| `images.<image-id>.env`                  | `dict[str, str]`      | <p>Environment variables passed to the image builder.</p><p>For more information, see <a href="..#images-less-than-image-id-greater-than-env"><code>images.\<image-id>.env</code> attribute</a>.</p>                                                                                                                                         |
| `images.<image-id>.volumes`              | `list[str]`           | <p>A sequence of volume definitions passed to the image builder.</p><p>For more information, see <a href="..#images-less-than-image-id-greater-than-volumes"><code>images.\<image-id>.volumes</code> attribute.</a></p>                                                                                                                      |

### `multi` context

The additional arguments passed to *multi-job*.

| Property name  | Type  | Description                                                                                                                                                                                                                                                                                                                                                                                             |
| -------------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `multi.args`   | `str` | <p>Additional command line arguments passed to <em>multi-job</em>.<br>The command line run defines the field as <code>apolo-flow run \<job-id> -- \<args></code>.</p><p><code>multi.args</code> is mainly used for passing args to command line parameters accepted by <em>multi-job</em>, see <a href="..#jobs-less-than-job-id-greater-than-cmd"><code>jobs.\<job-id>.cmd</code></a> for details.</p> |
| `multi.suffix` | `str` | *multi-job* suffix added to [`jobs.<job-id>`](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax/..#jobs-job-id-env).                                                                                                                                                                                                                                                |

### `params` context

Parameter described in the [`jobs.<job-id>.params` attribute](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax/..#jobs-less-than-job-id-greater-than-params) and available for substitution - for example, in [`jobs.<job-id>.cmd`](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax/..#jobs-less-than-job-id-greater-than-cmd) calculation.

| Property name         | Type  | Description                        |
| --------------------- | ----- | ---------------------------------- |
| `params.<param-name>` | `str` | The value of a specific parameter. |

Supported parameter values: `project`, `flow`, `env`, `tags`, `volumes`, `images`.

### `tags` context

A set of job tags.

Tags are combined from system tags (`project:<project-id>`, `job:<job-id>`), flow default tags (see [`defaults.tags` attribute](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax/..#defaults-tags)), and job-specific tags (see `jobs.<job-id>.tags` attribute).

| Property name | Type       | Description                                                                  |
| ------------- | ---------- | ---------------------------------------------------------------------------- |
| `tags`        | `set[str]` | This context changes for each job. You can access this context from any job. |

### `volumes` context

Contains information about volumes defined in the [`volumes` section ](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax/..#volumes)of a *live* workflow.

| Property name                         | Type                  | Description                                                                                                                                                                                                                                                                                                                                         |
| ------------------------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `volumes.<volume-id>.id`              | `str`                 | The volume definition identifier. For more information, see [`volumes.<volume-id>` section](https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax/..#volumes-less-than-volume-id-greater-than).                                                                                                                     |
| `volumes.<volume-id>.remote`          | `URL`                 | <p>Remote volume URI, e.g. <code>storage:path/to</code>.<br>For more information, see <a href="..#volumes-less-than-volume-id-greater-than-remote"><code>volumes.\<volume-id>.remote</code> attribute</a>.</p>                                                                                                                                      |
| `volumes.<volume-id>.mount`           | `RemotePath`          | <p>The path inside a job by which the volume should be mounted.</p><p>For more information, see <a href="..#volumes-less-than-volume-id-greater-than-mount"><code>volumes.\<volume-id>.mount</code> attribute</a>.</p>                                                                                                                              |
| `volumes.<volume-id>.read_only`       | `bool`                | <p><code>True</code> if the volume is mounted in read-only mode, <code>False</code> otherwise.</p><p>For more information, see <a href="..#volumes-less-than-volume-id-greater-than-read_only"><code>volumes.\<volume-id>.read\_only</code> attribute</a>.</p>                                                                                      |
| `volumes.<volume-id>.local`           | `LocalPath`or `None`  | <p>A path in the workspace folder to synchronize with remote Apolo storage or <code>None</code> if not set.</p><p>For more information, see <a href="..#volumes-less-than-volume-id-greater-than-local"><code>volumes.\<volume-id>.local</code> attribute</a>.</p>                                                                                  |
| `volumes.<volume-id>.full_local_path` | `LocalPath` or `None` | Full version of `local` property.                                                                                                                                                                                                                                                                                                                   |
| `volumes.<volume-id>.ref`             | `str`                 | <p>A volume reference that can be used as a <a href="..#jobs-less-than-job-id-greater-than-volumes"><code>jobs.\<job-id>.volumes</code> item</a>. The calculated value looks like <code>storage:path/to:/mnt/path:rw</code>.</p><p>The value is assembled from <code>remote</code>, <code>mount</code>, and <code>read\_only</code> properties.</p> |
| `volumes.<volume-id>.ref_ro`          | `str`                 | Like `ref` but *read-only* mode is enforced.                                                                                                                                                                                                                                                                                                        |
| `volumes.<volume-id>.ref_rw`          | `str`                 | Like `ref` but *read-write* mode is enforced.                                                                                                                                                                                                                                                                                                       |

### `git` context

The `git` context contains a mapping of your flow's workspace to a git repository.

This context can only be used if the flow's workspace is inside some git repository.

| Property name | Type        | Description                                    |
| ------------- | ----------- | ---------------------------------------------- |
| `git.sha`     | `str`       | SHA of the current commit.                     |
| `git.branch`  | `str`       | Name of the current branch.                    |
| `git.tags`    | `list[str]` | List of tags that point to the current commit. |
