我正在学习 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/