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

Azure DevOps管道用服务容器报错:Unexpected value 'stages'

Azure DevOps管道报错Unexpected value 'stages'排查与修复

错误原因

根层级的services配置和stages不能共存——services在多阶段管道中属于job级别的属性,只能定义在具体的job内部,不能直接放在根层级与stages并列。根层级的services仅适用于无stages的单job管道结构。

修改后的配置文件

主配置azure-pipelines.yml

trigger: none
pr: none

resources:
  containers:
    - container: playwright
      image: mcr.microsoft.com/playwright:v1.29.0-focal
    - container: pwsh
      image: mcr.microsoft.com/powershell

pool:
  vmImage: "ubuntu-latest"

stages:
  - stage: dev
    displayName: dev
    jobs:
      - template: templates/test.yml

模板文件templates/test.yml

- job: run_tests
  displayName: Test
  # 将services移到job内部
  services:
    playwright: playwright
    pwsh: pwsh
  steps:
    - powershell: |
        Write-Host "This is powershell"
      target:
        container: pwsh
    - script: yarn test:integration:ci
      displayName: "Run tests"
      env:
        environment: dev
        CI: true
      target:
        container: playwright

额外说明

  • 模板中的pool配置可以删除,因为主配置已经指定了ubuntu-latest代理池,避免重复定义。
  • 修改后管道会正确识别stages结构,同时job会加载指定的服务容器,执行对应容器内的步骤。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 11:05:19