Skip to content

Clarify usage of env.ENV_VAR instead of $ENV_VAR in when conditions #2922

@dam-ease

Description

@dam-ease

When using a condition within the when block of YAML script, referencing environment variables with $ENV_VAR, as done in other parts of the YAML script, results in an error:

When condition '$SHOREBIRD_ENABLED == "true"' is invalid: 'unexpected char '$' at 0
line 1'

The right approach is to use env.ENV_VAR instead of $ENV_VAR when referencing the environment variables. This distinction is not explicitly stated in the documentation. Although env.ENV_VAR is used in the example code snippet provided in the documentation, there is no clear explanation or note highlighting this requirement. https://docs.codemagic.io/yaml-running-builds/starting-builds-automatically/#using-condition-inside-when.

Updating the docs to state the requirement to use env.ENV_VAR in when conditions would give more clarity.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions