title | description | ms.date | monikerRange |
---|---|---|---|
stages.template definition |
You can define a set of stages in one file and use it multiple times in other files. |
03/02/2023 |
>=azure-pipelines-2020 |
:::moniker range=">=azure-pipelines-2020"
You can define a set of stages in one file and use it multiple times in other files.
:::moniker-end
:::moniker range=">=azure-pipelines-2020"
stages:
- template: string # Required as first property. Reference to a template for this stage.
parameters: # Parameters used in a stage template.
:::moniker-end
:::moniker range=">=azure-pipelines-2020"
Definitions that that reference this definition: stages
:::moniker-end
:::moniker range=">=azure-pipelines-2020"
template
string. Required as first property.
Reference to a template for this stage.
:::moniker-end
:::moniker range=">=azure-pipelines-2020"
parameters
template parameters.
Parameters used in a stage template.
:::moniker-end
Reference the stage template in the main pipeline.
- template: string # name of template to include
parameters: { string: any } # provided parameters
Define the stages in the template.
parameters: { string: any } # expected parameters
stages: [ stage ]
In this example, a stage is repeated twice for two different testing regimes. The stage itself is specified only once.
# File: stages/test.yml
parameters:
name: ''
testFile: ''
stages:
- stage: Test_${{ parameters.name }}
jobs:
- job: ${{ parameters.name }}_Windows
pool:
vmImage: windows-latest
steps:
- script: npm install
- script: npm test -- --file=${{ parameters.testFile }}
- job: ${{ parameters.name }}_Mac
pool:
vmImage: macos-latest
steps:
- script: npm install
- script: npm test -- --file=${{ parameters.testFile }}
# File: azure-pipelines.yml
stages:
- template: stages/test.yml # Template reference
parameters:
name: Mini
testFile: tests/miniSuite.js
- template: stages/test.yml # Template reference
parameters:
name: Full
testFile: tests/fullSuite.js