Azure Devops: Is it possible to nest yaml templates inside another yaml template?
It seems like there is an indentation mistake in your BuildSolution.yml. parameters and jobs should have the same indentation. refer to below:
parameters:
buildArtifactName: "build"
solution: ""
jobs:
- job: 'BuildSolution'
pool:
vmImage: ${{parameters.vmImage}}
continueOnError: false
variables:
artifactName: ${{ parameters.buildArtifactName}}
steps:
- task: NuGetCommand@2
displayName: 'Restore NuGet packages'
inputs:
restoreSolution: ${{ parameters.solutionDir }}/${{ parameters.solution }}
configuration: ${{parameters.buildConfiguration}}
You can reference four kinds of templates within Azure Pipelines: Stage, Job, Step and Variable.
An example (with slightly modified comments by me) taken from the "Template References" documentation is as follows:
# File: azure-pipelines.yml which references another YAML file (test.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
And the test.yml file is as follows:
# File: test.yml file to be referenced by the azure-pipelines.yml file
parameters:
name: ''
testFile: ''
stages:
- stage: Test_${{ parameters.name }}
jobs:
- job: ${{ parameters.name }}_Windows
pool:
vmImage: vs2017-win2016
steps:
- script: npm install
- script: npm test -- --file=${{ parameters.testFile }}
- job: ${{ parameters.name }}_Mac
pool:
vmImage: macos-10.13
steps:
- script: npm install
- script: npm test -- --file=${{ parameters.testFile }}