首页 > 解决方案 > 限制 Azure DevOps Pipeline 中的并行作业数量

问题描述

我想将工作限制为 parallel-10 。我的总工作量约为 150。如何在下面的 yaml 结构中定义“策略:并行”。我为每个循环创造了 100 多个工作。因此需要 1 多个小时才能完成,并且还使用了所有代理。所以想限制代理。有人可以帮忙吗?

下面的代码:

stages:
- stage: xxx
  jobs:
      - ${{ each v in parameters.vvv }}:
        - template: Templates/aa.yml
          parameters:

标签: azureazure-devopsazure-pipelines-yaml

解决方案


如文档中所述,使用具有parallelormatrix策略的作业。您可以设置最大并行度。

jobs:
- job: string  # name of the job (A-Z, a-z, 0-9, and underscore)
  strategy:
    parallel: # parallel strategy; see the following "Parallel" topic
    matrix: # matrix strategy; see the following "Matrix" topic
    maxParallel: number # maximum number of matrix jobs to run simultaneously

推荐阅读