I am trying to learn azure devops yaml and uses template.
Here is my pipeline yaml (basically wants to set a parameter and call a template file):
trigger:
branches:
include:
- master
paths:
exclude:
- YAML/*
extends:
template: azure-pipeline.yaml
parameters:
MergeSprintToMaster: false
Here is my template file azure-pipeline.yaml, which contains all commons things:
parameters:
- name: MergeSprintToMaster # name of the parameter; required
type: boolean # data type of the parameter; required
default: false
pool:
name: Azure Pipelines
vmImage: 'windows-latest'
demands:
- msbuild
- visualstudio
- vstest
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: AzureCLI@2
I got an validation error saying /YAML/azure-pipeline.yaml (Line: 11, Col: 1): Unexpected value 'pool'
What is wrong with the way I am trying to use yaml?
Apparently you can't have the pool
top-level in your template when the template is targeted by an extends
.
See https://developercommunity.visualstudio.com/content/problem/992713/unexpected-value-pool-when-extending-a-template.html and https://github.com/microsoft/azure-pipelines-yaml/issues/430
Use the following instead:
parameters:
- name: MergeSprintToMaster # name of the parameter; required
type: boolean # data type of the parameter; required
default: false
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
jobs:
- job:
pool:
name: Azure Pipelines
vmImage: 'windows-latest'
demands:
- msbuild
- visualstudio
- vstest
steps:
- task: AzureCLI@2
Product team have confirmed currently pool
cannot be included in the top level pipeline when that pipeline uses extends:
https://github.com/MicrosoftDocs/azure-devops-docs/issues/7972#issuecomment-618988624
extends
currently requires an explicit jobs:
or stages:
wrapper even in the case of a single job. The two rules are:
extends
, then only trigger
, pr
, schedule
, and resources
can appear at the top level alongside extends
.extends
, then it must have at least a jobs
level specified.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With