How to Use a Template with Parameters in Azure Pipelines
A template with a parameters block becomes a reusable step set you call with arguments.
Define parameters in a template file and reference its parameters with the template expression syntax. The caller passes values, keeping shared logic in one place.
Define and call a parameterized template
The template declares typed parameters; the caller passes them under parameters.
azure-pipelines.yml
# build-template.yml
parameters:
- name: nodeVersion
type: string
default: '20'
steps:
- task: NodeTool@0
inputs:
versionSpec: '${{ parameters.nodeVersion }}'
- script: npm ci && npm test
# azure-pipelines.yml
steps:
- template: build-template.yml
parameters:
nodeVersion: '22'Notes
- Template parameter syntax ${{ parameters.x }} is resolved at compile time, before the run starts.
- Typed parameters (string, boolean, object, stepList) are validated when the pipeline compiles.
Related guides
How to Run a Script Step with Bash in Azure PipelinesRun shell commands in Azure Pipelines with the Bash@3 task so scripts execute under bash on Linux and macOS a…
How to Set Pipeline-Level Variables in Azure PipelinesDefine variables at the pipeline level in Azure Pipelines so every job and step can read them with the $(Var)…