azure - 如何在 Azure Pipelines 中跨多个阶段传播矩阵定义
问题描述
我正在 Azure Pipelines 中编写一个多阶段作业,其中涉及从脚本生成矩阵作为阶段的输出。我想在多个阶段使用该矩阵来生成作业,但我想在使用该矩阵的前一阶段的作业上使用条件。
示例 azure-pipelines.yml:
stages:
- stage: A
jobs:
- job: generateMatrix
- stage: B
dependsOn: A
jobs:
- job: "" # This lets the job name be just the name of the matrix key
continueOnError: true # steps in these jobs may or may not fail
strategy:
matrix: $[ stageDependencies.A.generateMatrix.outputs['matrix'] ]
- stage: C
dependsOn: # Needs A's matrix and B job results
- A
- B
jobs:
- job: "" # The job name here should be the same as in stage B
continueOnError: true
strategy:
matrix: $[ stageDependencies.A.generateMatrix.outputs['matrix'] ]
steps:
- script: echo "Job from Stage B Succeeded"
condition: eq(stageDependencies.B.variables['Agent.JobName'].result, 'Succeeded')
- script: echo "Job from Stage B Failed"
condition: condition: ne(stageDependencies.B.variables['Agent.JobName'].result, 'Succeeded')
所以我需要具备以下能力之一:
- 能够参数化阶段依赖项内的 json 路径
- 能够编辑变量并将其添加到阶段 (B) 中的现有矩阵并以某种方式输出该变量。
有谁知道如何做到这一点?我尝试了上述方法,但失败了。
解决方案
恐怕我们无法在 Stage B 中修改 Stage A 的矩阵输出。您需要在 Stage B 中定义一个新的输出,然后在 Stage C 中使用。
推荐阅读
- docker - npm install -g apiconnect 在 Docker 容器 (RHEL8) 中失败
- android - PagingData 在 Paging 3 库中是否默认在后台线程上运行?
- node.js - 如何在 TypeORM 实体中指定 SQL Server 计算列?
- applescript - 苹果脚本新手
- ios - 列表部分标题的 SwiftUI 2 清除背景
- linux - 使用 ansible playbook 处理目标环境(dev/prod/systest)的 YUM 包安装部署
- ios - SwiftUI 旋转屏幕使模态不再自行消失
- html - CSS无法在主要内容中向下滚动
- javascript - getelementbyid 在 iframe 中加载页面
- r - 使用 mstate::msprep 的错误消息??错误?