yaml文件问题“在此上下文中不允许使用映射值”

时间:2019-10-15 09:18:02

标签: azure-devops yaml azure-pipelines

我正在学习Azure DevOps管道。我在YAML文件中遇到错误,无法修复它。有人可以帮我吗?

以下是错误:

  

():在此上下文中,第3行不允许映射值   第11栏

我一直在使用www.yamllint.com/进行修复,但是没有运气。 (默认情况下,代码的task:PowerShell@2部分是通过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 个答案:

答案 0 :(得分:1)

您应该将任务放在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'

我也修复了缩进,请比较我的yaml与您的yaml,以准确了解我的工作。