I create an Azure-Pipelines file that starts as follows:
pool:
vmImage: 'Ubuntu-16.04'
trigger:
- master
variables:
buildConfiguration: 'Release'
buildPlatform: 'any cpu'
version: '0.2.0'
azureSubscription: 'Azure.Nupaya'
azureAppType: 'Web App on Windows'
webAppName: 'api'
stages:
- stage: 'Prepare'
displayName: 'Prepare'
jobs:
- job: 'Setup'
steps:
- task: DotNetCoreInstaller@0
displayName: 'Install'
inputs:
packageType: 'sdk'
version: '2.2.105'
When I run it I get the error:
Unexpected value 'stages'
Isn't Stages supported in the Yaml File?
I checked the Schema in Microsoft Docs ...
What am I missing?
After some playing and testing with the Azure DevOps it seems that you define the pool under the job property, as to allow us to define different agent pools for different jobs.
So for your example it would be:
trigger:
- master
variables:
buildConfiguration: 'Release'
buildPlatform: 'any cpu'
version: '0.2.0'
azureSubscription: 'Azure.Nupaya'
azureAppType: 'Web App on Windows'
webAppName: 'api'
stages:
- stage: 'Prepare'
displayName: 'Prepare'
jobs:
- job: 'Setup'
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: DotNetCoreInstaller@0
displayName: 'Install'
inputs:
packageType: 'sdk'
version: '2.2.105'
My issue was that I was using the key services:
which must be nested under a job.
The offending code came directly from these azure docs. They show services:
being used directly at the root of the yaml document. However, this only worked in the docs because the implied scope was job
when no jobs or stages are specified, as in their example. Moving services:
under the job(s) where it was needed fixed the problem.
Example from Azure Docs:
resources:
containers:
- container: my_container
image: buildpack-deps:focal
- container: nginx
image: nginx
pool:
vmImage: 'ubuntu-20.04'
container: my_container
services:
nginx: nginx
steps:
- script: |
curl nginx
displayName: Show that nginx is running
Notice that they are using steps:
at the root instead of stages:
. This caused my problem.
If you run into this problem, or the related problems with jobs:
, figure out which root key is causing the error by commenting out one key at a time, especially newly added keys. Once you find it, check the YAML Schema definition to see if that key is allowed in the scope that's implied. Pay special attention to the implied scope if steps:
, jobs:
or stages:
is used as a root key.
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