我想在 Azure 管道中设置我的 CI 以在以下位置运行我的测试:
- Python 3.6/Linux
- Python 3.7/Linux
- Python 3.6/Windows
- Python 3.7/Windows
我看到我可以通过使用 matrix 轻松地测试不同的 Python 版本,但我猜测是否有一种简单的方法可以对图像执行相同的操作。我认为可以为其使用模板,但如果可以的话,我希望将所有内容保持简单并放在一个文件中。
这是我目前在 Linux 中测试 py3.6/py3.7 的结果:
- job: 'Test'
pool:
vmImage: 'Ubuntu 16.04'
strategy:
matrix:
Python36:
python.version: '3.6'
Python37:
python.version: '3.7'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'
- script: python -m unittest discover tests
displayName: 'Run unittest tests'
请您参考如下方法:
看起来没有办法用类似矩阵的方式来实现这个(它应该在未来的某个时候实现)。这两个选项是:
使用 template在单独的文件中定义步骤,并使用不同的图像调用模板
为每个
vmImage设置一个作业,并重复每个作业中的步骤
来源:https://github.com/MicrosoftDocs/vsts-docs/issues/1855#issuecomment-425191025
