Reputation: 4375
My current pipeline consists of 2 files: pr-validation.yml
resources:
- repo: self
queue:
name: NonProd
variables:
- name: 'NuGetFeedId'
value: '11111b1d-1111-1ecb-1dc1-11f111111f11'
steps:
- template: pr-validation-steps.yml
parameters:
UnitTestsProjectPaths:
- '1.Tests/1.Tests.csproj'
- '2/2.Tests/2.Tests.csproj'
- '3/3.Tests/3.Tests.csproj'
and actual steps in pr-validation-steps:
parameters:
- name: UnitTestsProjectPaths
type: object
default:
- '1.Tests/1.Tests.csproj'
- '2/2.Tests/2.Tests.csproj'
- '3/3.Tests/3.Tests.csproj'
steps:
- task: DotNetCoreCLI@2
displayName: 'NuGet restore'
inputs:
command: 'restore'
vstsFeed: '$(NuGetFeedId)'
projects: '**/*.sln'
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '**/*.sln'
arguments: '--no-restore'
- ${{ each UnitTestsProjectPath in parameters.UnitTestsProjectPaths }}:
- task: DotNetCoreCLI@2
displayName: 'Run unit tests in ${{ UnitTestsProjectPath }} and collect coverage'
inputs:
command: 'test'
projects: '${{ UnitTestsProjectPath }}'
arguments: '--configuration $(buildConfiguration) --collect "Code coverage" --no-restore'
As you see I'm on pre-build validation for .NET Core projects and the current fragment is about running several test projects from solution, but not all of them.
Azure DevOps is saying: 'pr-validation-steps.yml (Line: 2, Col: 1): Expected a mapping'
Basically saying that something's wrong in at the beginning of the line with a 'name' entry. I tried different syntax options but nothing worked for me.
I validated the files with Tom Austin's 'Azure Pipeline YAML Validator' and it says everything's fine.
What am I doing wrong? And in case you're using any kind of effective pipeline validator - please let me know, I really need it.
Upvotes: 0
Views: 6020
Reputation: 40779
First you have this
queue:
name: NonProd
which I don't recognize and Azure DevOps also.
When you remove it you should be fine.
And speaking about validator. The only one good which I know is the one on the Azure Devops:
I tested this with following:
build.yml
trigger: none
pool:
vmImage: ubuntu-latest
variables:
- name: 'NuGetFeedId'
value: '11111b1d-1111-1ecb-1dc1-11f111111f11'
steps:
- template: pr-validation-steps.yml
parameters:
UnitTestsProjectPaths:
- '1.Tests/1.Tests.csproj'
- '2/2.Tests/2.Tests.csproj'
- '3/3.Tests/3.Tests.csproj'
pr-validation-steps.yml
parameters:
- name: UnitTestsProjectPaths
type: object
default:
- '1.Tests/1.Tests.csproj'
- '2/2.Tests/2.Tests.csproj'
- '3/3.Tests/3.Tests.csproj'
steps:
- ${{ each UnitTestsProjectPath in parameters.UnitTestsProjectPaths }}:
- bash: echo 'Run unit tests in ${{ UnitTestsProjectPath }} and collect coverage'
And it works.
Upvotes: 2