gpt4 book ai didi

matrix - Azure Pipelines 数据驱动矩阵

转载 作者:行者123 更新时间:2023-12-05 03:51:26 24 4
gpt4 key购买 nike

在 GitHub Actions 中,我可以像这样编写一个矩阵作业:

jobs:
test:
name: Test-${{matrix.template}}-${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
template: ['API', 'GraphQL', 'Orleans', 'NuGet']
steps:
#...

这将运行 ostemplate 的所有组合。在 Azure Pipelines 中,您必须像这样手动指定每个组合:

stages:
- stage: Test
jobs:
- job: Test
strategy:
matrix:
Linux:
os: ubuntu-latest
template: API
Mac:
os: macos-latest
template: API
Windows:
os: windows-latest
template: API
# ...continued
pool:
vmImage: $(os)
timeoutInMinutes: 20
steps:
#...

是否可以创建类似于 GitHub Actions 的数据驱动矩阵策略?

最佳答案

Is it possible to create a data driven matrix strategy similar to GitHub Actions?

答案是肯定的。这是一个已在 github 上报告的已知问题:

Add cross-product matrix strategy

此外,在 official documentation 中有提到此问题的解决方法:

Note

The matrix syntax doesn't support automatic job scaling but you canimplement similar functionality using the each keyword. For anexample, see nedrebo/parameterized-azure-jobs.

jobs:
- template: azure-pipelines-linux.yml
parameters:
images: [ 'archlinux/base', 'ubuntu:16.04', 'ubuntu:18.04', 'fedora:31' ]
pythonVersions: [ '3.5', '3.6', '3.7' ]
swVersions: [ '1.0.0', '1.1.0', '1.2.0', '1.3.0' ]
- template: azure-pipelines-windows.yml
parameters:
images: [ 'vs2017-win2016', 'windows-2019' ]
pythonVersions: [ '3.5', '3.6', '3.7' ]
swVersions: [ '1.0.0', '1.1.0', '1.2.0', '1.3.0' ]

azure-pipelines-windows.yml:

jobs:
- ${{ each image in parameters.images }}:
- ${{ each pythonVersion in parameters.pythonVersions }}:
- ${{ each swVersion in parameters.swVersions }}:
- job:
displayName: ${{ format('OS:{0} PY:{1} SW:{2}', image, pythonVersion, swVersion) }}
pool:
vmImage: ${{ image }}
steps:
- script: echo OS version &&
wmic os get version &&
echo Lets test SW ${{ swVersion }} on Python ${{ pythonVersion }}

关于matrix - Azure Pipelines 数据驱动矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62879511/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com