Azure DevOps-矩阵策略 - 有条件的工作运行
*请忽略格式问题
trigger:
- none
parameters:
- name: stg
displayName: "Environment Names"
type: string
pool:
vmImage: ubuntu-latest
stages:
- stage: stage1
displayName: 'Stage C1'
jobs:
- job: jobabc
strategy:
maxParallel: 2
matrix:
env_1:
EnvironmentX: E1
Browser: IE
env_2:
EnvironmentX: E2
Browser: Firefox
env_3:
EnvironmentX: E3
Browser: Chrome
displayName: 'Job 1'
condition: contains('${{parameters.stg}}', $(EnvironmentX))}}
steps:
- task: CmdLine@2
displayName: 'My Task '
inputs:
script: 'echo Stage C1 $(Browser)'
I通过stg
参数为e1e3e4
。
在矩阵中,i已定义vosingsx
,其值可以为e1,e2或e3
。
下面的代码在定义的矩阵值的情况下运行3次作业。
我不想运行所有3个作业,但是STG参数值应该决定作业将运行哪个矩阵值。
工作状况不起作用?请解决这个问题
*please ignore formatting issue
trigger:
- none
parameters:
- name: stg
displayName: "Environment Names"
type: string
pool:
vmImage: ubuntu-latest
stages:
- stage: stage1
displayName: 'Stage C1'
jobs:
- job: jobabc
strategy:
maxParallel: 2
matrix:
env_1:
EnvironmentX: E1
Browser: IE
env_2:
EnvironmentX: E2
Browser: Firefox
env_3:
EnvironmentX: E3
Browser: Chrome
displayName: 'Job 1'
condition: contains('${{parameters.stg}}', $(EnvironmentX))}}
steps:
- task: CmdLine@2
displayName: 'My Task '
inputs:
script: 'echo Stage C1 $(Browser)'
I pass stg
parameter as E1E3E4
.
In Matrix I have defined EnvironmentX
whose value can be E1, E2, or E3
.
Below code runs Job 3 times with matrix values defined.
I do NOT want to run all 3 jobs but stg parameter value should decide JOb would run for which matrix values.
Job Condition is NOT working? How to fix this please
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以有条件地构建矩阵。不理想,但这会起作用:
You could build the matrix conditionally. Not ideal but that will work: