我想从另一个pytest模板yaml在主管道中执行pytest
# test-template.yml
parameters:
- name: jobName
type: string
jobs:
- job: ${{ parameters.jobName }}
steps:
- task: UsePythonVersion@0
displayName: ${{ parameters.jobName }}
inputs:
versionSpec: some_python_version
script: |
if [ "${{ parameters.jobName }}" = "Pytest1" ]; then
pytest -v tests -k "pretest_case1"
elif [ "${{ parameters.jobName }}" = "Pytest2" ]; then
pytest -v tests -k "postTest_case2"
else
# Handle any other jobName value or add an error message if needed.
echo "Invalid jobName: ${{ parameters.jobName }}"
exit 1
fi
字符串
Main.yaml
trigger:
- main
stages:
- stage: test_int1
pool:
vmImage: 'ubuntu'
jobs:
- template: test-template.yml
parameters:
jobName: 'Pytest1'
- stage: test_int2
pool:
vmImage: 'ubuntu'
jobs:
- template: test-template.yml
parameters:
jobName: 'Pytest2'
型
但是在测试这个管道时,它抛出错误
“上下文中不允许使用if指令。嵌入在字符串”“中的表达式不应使用指令
对此有什么解决办法吗?
1条答案
按热度按时间hivapdat1#
UsePythonVersion
没有input script字符串
你应该使用
PythonScript
型
你可以试试这样的
型