Azure Devops管道动态创建的阶段以按顺序/序列运行相当平行
我目前正在基于输入参数动态创建多个阶段的Azure Pipeline,并希望以序列而不是并行运行 stage2_stg_x (当前并行运行)。我找不到任何可能的解决方案来实现这一目标。
有人可以在这里建议吗?
主管道:test.yml
trigger: none
pool:
name: 'linuxagent'
parameters:
- name: appComponents
displayName: YAML list of Components to Build and Deploy
type: object
default:
- stg_a
- stg_b
- stg_c
- stg_d
- stg_e
stages:
- template: pipeline/stages/stage1.yml
- ${{ each appComponents in parameters.appComponents }}:
- template: pipeline/stages/stage2.yml
parameters:
appComponents: ${{ appComponents }}
stage1.yml
stages:
- stage: stage1
dependsOn: []
displayName: stage1
jobs:
- job:
steps:
- bash: |
# Write your commands here
echo "Hello world"
echo "i am here"
stage2.ym stage2.yml
parameters:
- name: appComponents
displayName: "Component name"
type: object
stages:
- stage: stage2_${{ replace(parameters.appComponents, '-', '_') }}
dependsOn: stage1
displayName: stage2 For ${{ parameters.appComponents }}
jobs:
- job:
steps:
- bash: |
# Write your commands here
echo "Hello world"
echo "i am here"
:在这里我只使用基本回声进行测试目的。但是我的实际管道具有不同的逻辑。
I am currently working on azure pipeline with multiple stages created dynamically based on the input parameter(s), and want to run the stage2_stg_x in sequence rather than parallel(currently it runs in parallel). I couldn't found any possible solution to get that achieved.
Could someone suggest here.
main pipeline : test.yml
trigger: none
pool:
name: 'linuxagent'
parameters:
- name: appComponents
displayName: YAML list of Components to Build and Deploy
type: object
default:
- stg_a
- stg_b
- stg_c
- stg_d
- stg_e
stages:
- template: pipeline/stages/stage1.yml
- ${{ each appComponents in parameters.appComponents }}:
- template: pipeline/stages/stage2.yml
parameters:
appComponents: ${{ appComponents }}
stage1.yml
stages:
- stage: stage1
dependsOn: []
displayName: stage1
jobs:
- job:
steps:
- bash: |
# Write your commands here
echo "Hello world"
echo "i am here"
stage2.yml
parameters:
- name: appComponents
displayName: "Component name"
type: object
stages:
- stage: stage2_${{ replace(parameters.appComponents, '-', '_') }}
dependsOn: stage1
displayName: stage2 For ${{ parameters.appComponents }}
jobs:
- job:
steps:
- bash: |
# Write your commands here
echo "Hello world"
echo "i am here"
Note : Here i have just using the basic echo for testing purpose. But my actual pipeline has different logic.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试从所有阶段中删除“依赖子”。
我也有类似的设置,阶段都取决于他们之前的阶段。
Try removing "dependsOn" from all your stages.
I have a similar setup and the stages all just depend on the stage before them.