Azure 管道 - "Stages to run" 不工作

Azure pipelines - "Stages to run" does not work

在多阶段管道上单击新功能 "Stages to run",我收到错误消息 "Unable to load the pipeline's stages." 此功能是否仍处于某种预览状态?

以下 Yaml 文件:

    ================== azure-pipelines.yml =============

    trigger: none

    variables:
      - group: var-group

      - name: PREFIX
        value: xyz

    stages:
      - stage: build_and_push
        displayName: Build/Push stage
        jobs:
        - template: build-template-job.yml
          parameters:
            countries:
              - name: Austria
                country_code: AT
              - name: Switzerland
                country_code": CH

      - stage: deploy
        displayName: Deploy stage
        jobs:
        - template: deploy-template-job.yml
          parameters:
            countries:
              - name: Austria
                country_code: AT
              - name: Switzerland
                country_code": CH

    ================== build-template-job.yml =============


    parameters:
      countries: []

    jobs:

    - job: Build_1
      pool:
        vmImage: 'Ubuntu-16.04'
      continueOnError: false
      displayName: "Building 1"

      steps:
        - task: HelmInstaller@0
          displayName: 'Install Helm'
          inputs:
            helmVersion: 2.14.3
            checkLatestHelmVersion: false

        - bash: helm package
            --version 1.0.0
            --destination $(build.artifactStagingDirectory)
            helm/
          displayName: 'Packaging the heml chart....'


    - ${{ each country in parameters.countries}}:

        # more steps....```

无法加载管道阶段的错误可能表示您的 yaml 管道中存在一些错误(例如语法错误、缩进错误)。

我在多阶段管道上进行了测试。它运作良好。但是当我故意在我的管道中放一个错误时,我得到了和你一样的错误。

您可以尝试 运行 以正常方式连接您的管道,而无需选择要跳过的阶段。如果管道中存在格式错误,管道将无法启动。

如果您的管道可以 运行 在不使用此功能的情况下成功。请分享您的示例管道,以便我可以重现您的场景并进行故障排除。

Update:

我测试了你的yaml,发现在stages外定义的变量组导致了这个错误。如果您在每个阶段内移动变量组,该功能将再次起作用。

您可以尝试在每个阶段定义您的变量组。要报告此问题,您可以单击 here(单击报告问题并选择 Azure Devops)

已解决:我将组定义移动到阶段级别而不是 azure 管道文件的顶部。

示例:

stages:
  - stage: build
    variables:
      - group: my-var-group
  - stage: deploy
    variables:
      - group: my-var-group