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.
##[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.
variables:
buildConfig: Release
steps:
- script: dotnet build -c \$(buildConfig)Match the reference name exactly
- Confirm the variable name and casing in
variables:or the linked variable group. - Update the input macro to use the exact same name.
- 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.