yaml file issue "mapping values are not allowed in this context"

Viewed 16313

I am learning Azure DevOps pipelines. I am getting an error in the YAML file and having difficulty to fix it. Could someone please help me out?

Below is the error:

(): mapping values are not allowed in this context at line 3 column 11

I have been using www.yamllint.com/ to fix, but no luck. (The task:PowerShell@2 part in the code is added by default from the "task" option from the Azure DevOps).

# Starter pipeline
- task:PowerShell@2
    inputs:
  filePath:'$(System.DefaultWorkingDirectory)/_learndevops/HelloWorld.ps1'
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
- task:PublishBuildArtifacts@1
  inputs:
    PathtoPublish:'$(Build.ArtifactStagingDirectory)'
    ArtifactName:'drop'
    publishLocation:'Container'
# https://aka.ms/yaml

trigger:
- master

pool:
  vmImage:'ubuntu-latest'

steps:
- script:echo Hello, world!
1 Answers

You should put the tasks after the steps:

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- master

pool:
  vmImage:'ubuntu-latest'

steps:
- script: echo Hello, world!

- task: PowerShell@2
  inputs:
   filePath: '$(System.DefaultWorkingDirectory)/_learndevops/HelloWorld.ps1'

- task: PublishBuildArtifacts@1
  inputs:
   PathtoPublish: '$(Build.ArtifactStagingDirectory)'
   ArtifactName: 'drop'
   publishLocation: 'Container'

I also fixed the indentation, please compare my yaml to yours to see exactly what I'm did.

Related