Skip to content
Latchkey

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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →