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

Man*_*Rao 3 yaml azure-devops 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!
Run Code Online (Sandbox Code Playgroud)

Sha*_*zyk 12

你应该把任务放在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'
Run Code Online (Sandbox Code Playgroud)

我还修复了缩进,请将我的 yaml 与您的 yaml 进行比较,看看我做了什么。