我的管道中有以下 DotNet 测试任务
displayName: 'unit tests'
inputs:
command: test
projects: '**/*Unit*.csproj'
publishTestResults: true
arguments: '/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=results/'
如果没有文件与项目模式匹配,我如何使管道失败:'**/*Unit*.csproj'
?
当前,它显示当前的错误消息并移至下一个任务
##[warning]Project file(s) matching the specified pattern were not found.
答案 0 :(得分:0)
如果你的 yaml 管道中有阶段,那么你可以做这样的事情,如果前一个阶段失败,这将不会运行下一个阶段
stages:
- stage: unittests
displayName: 'unit tests'
- stage: nextstage
dependsOn: unittests
displayName: 'unit tests'
答案 1 :(得分:0)
使用 Visual Studio Test 任务。它有一个 minimumExpectedTests
参数,因此如果将其设置为 1,则在运行 0 个测试时任务将失败。
答案 2 :(得分:0)
据我所知,我们不能设置任务本身来使管道在找不到文件时失败。
解决方法:
您可以使用 Build Quality Checks extension 中的构建质量检查任务。
此任务可以扫描所有设置的任务并检查警告。如果警告次数大于设置的上限,管道将失败。
结果: