You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure DevOps使用YAML创建构建流水线报错,请求故障排查

你的YAML代码错误分析及修正

错误1:PublishBuildArtifacts@1任务的inputs块为空

你定义了PublishBuildArtifacts@1任务,但下面的inputs:没有配置任何参数,YAML不允许这种空的配置块,这就是触发Line:21, Col:10错误的直接原因。

错误2:参数混放

你把PublishBuildArtifacts@1的专属参数(PathtoPublish、ArtifactName、publishLocation)错误放到了AzurePowerShell@5任务的inputs里,导致任务配置结构混乱。


修正后的完整YAML代码

# 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:
- adf_publish

pool:
  vmImage: ubuntu-latest

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

- script: |
    echo Add other tasks to build, test, and deploy your project.
    echo See https://aka.ms/yaml
  displayName: 'Run a multi-line script'

# 修正后的 PublishBuildArtifacts 任务,补充完整 inputs 参数
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: 'caplogic-warehouse-dev-df'
    ArtifactName: 'drop'
    publishLocation: 'Container'

# 修正后的 AzurePowerShell 任务,移除不属于它的参数
- task: AzurePowerShell@5
  inputs:
    azureSubscription: 'NewConnectionName'
    ScriptType: 'FilePath'
    ScriptPath: '$(System.DefaultWorkingDirectory)/_Azure Data Factory-CP/drop/pre-and post-deployment.ps1'
    ScriptArguments: '-armTemplate "$(System.DefaultWorkingDirectory)/_Azure Data Factory-CP/drop/ARMTemplateForFactory.json" -ResourceGroupName $(ResourceGroup) -DataFactoryName $(DataFactory) -predeployment $true -deleteDeployment $false'
    azurePowerShellVersion: 'LatestVersion'

额外说明:你在ScriptArguments里用了HTML转义字符",在YAML中直接使用双引号"即可,已帮你同步修正。

内容的提问来源于stack exchange,提问作者Patterson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 23:57:19