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

新建项目(Docker-Linux)下Azure DevOps Pipeline构建失败

Azure DevOps Pipeline构建失败问题排查与修复

你的自动生成YAML存在缩进错误,YAML对层级缩进要求严格,以下是具体问题和修正后的配置:

原YAML的错误点

  • pool 节点下的 vmImage: $(vmImageName) 未缩进,导致语法错误
  • inputs 下的所有参数(command、repository等)均未正确缩进,破坏了层级结构
  • tags 列表中的 $(tag) 缺少缩进,不符合多行列表的语法要求

修正后的YAML配置

trigger:
- master

resources:
- repo: self

variables:
  dockerRegistryServiceConnection: '3cdd4a4c-****-****-****-132c5f7c77c0'
  imageRepository: '****'
  containerRegistry: 'directiocontainers.azurecr.io'
  dockerfilePath: '$(Build.SourcesDirectory)/Test3Pipeline/Dockerfile'
  tag: '$(Build.BuildId)'
  vmImageName: 'ubuntu-latest'

stages:
- stage: Build
  displayName: Build and push stage
  jobs:
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)
    steps:
    - task: Docker@2
      displayName: Build and push an image to container registry
      inputs:
        command: buildAndPush
        repository: $(imageRepository)
        dockerfile: $(dockerfilePath)
        containerRegistry: $(dockerRegistryServiceConnection)
        tags: |
          $(tag)

额外检查建议

  • 确认Dockerfile路径正确,$(Build.SourcesDirectory) 指向代码仓库根目录,确保Dockerfile确实存在于指定路径
  • 验证容器注册表服务连接(dockerRegistryServiceConnection)的权限配置正确,确保能正常推送镜像

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 15:35:59