Skip to content
Latchkey

Azure Pipelines "Step input X references undefined variable"

A task input (or a \$(var) macro inside one) names a variable that is not defined when the step is compiled. Azure surfaces this at validation time rather than silently passing an empty value, so the run never starts.

What this error means

The pipeline fails to compile, naming the step input and the variable it could not resolve. The task itself is valid; the variable reference inside one of its inputs is the problem.

azure-pipelines
##[error]Step input script references undefined variable 'BUILD_CONFIG'.

Common causes

Variable never defined or out of scope

The referenced variable is not declared in variables:, not imported from a variable group, or is scoped to a different stage/job than the step that reads it.

Typo or wrong casing in the reference

Macro references must match the variable name. A typo (BUILD_CONFIG vs buildConfig) leaves the input pointing at a name that does not exist.

How to fix it

Define the variable before the step uses it

Declare the variable in variables: (or pull it from a group) so the input can resolve.

azure-pipelines.yml
variables:
  buildConfig: Release
steps:
  - script: dotnet build -c \$(buildConfig)

Match the reference name exactly

  1. Confirm the variable name and casing in variables: or the linked variable group.
  2. Update the input macro to use the exact same name.
  3. Validate the pipeline so the reference resolves before a run.

How to prevent it

  • Define every variable a step input reads, in scope, before the step.
  • Keep variable names and macro references identical in casing.
  • Validate the pipeline so undefined-variable inputs surface early.

Frequently asked questions

What causes ""references undefined variable""?
The referenced variable is not declared in variables:, not imported from a variable group, or is scoped to a different stage/job than the step that reads it.
How do I fix "references undefined variable"?
Declare the variable in variables: (or pull it from a group) so the input can resolve.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card