azure-devops - yaml 文件问题 "mapping values are not allowed in this context"

标签 azure-devops yaml azure-pipelines

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

下面是错误:

(): mapping values are not allowed in this context at line 3 column 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!

最佳答案

你应该把任务放在 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 进行比较,看看我做了什么。

关于azure-devops - yaml 文件问题 "mapping values are not allowed in this context",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58391262/

相关文章:

Azure DevOps Pipeline 创建空 zip

解析 yaml-cpp 中的注释

azure-devops - 有条件地在 azure 管道中使用变量组

python-3.x - botocore.exceptions.ClientError : An error occurred (ExpiredTokenException) The security token included in the request is expired

powershell - 如何在 DevOps 管道上运行的 Powershell 上使用 key 保管库 secret

inheritance - YAML 中的继承更复杂?

azure - 在 Azure Pipelines 上安装编译器

azure - Azure 灾难恢复的替代方法

powershell - 是否可以重命名或为 VSTS 中的构建提供自定义名称?

asp.net-core - 当 dotnet 测试的覆盖率低于目标时,Azure DevOps 构建不会失败