This guy seems to have the same problem
这是我正在做的事情:
stage('Test') {
steps {
bat "\"${tool 'VSTestRunner'}\" %WORKSPACE%\\MyApp\\bin\\Debug\\MyApp.dll /logger:trx & exit 0"
// The test publish is responsible for decided whether the test stage failed
step([$class : 'XUnitPublisher',
testTimeMargin: '3000',
thresholdMode: 1,
thresholds: [
[$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: '1', unstableNewThreshold: '', unstableThreshold: ''],
[$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']
],
tools : [[$class: 'MSTestJunitHudsonTestType',
deleteOutputFiles: true,
failIfNotNew: false,
pattern: "TestResults\\*.trx",
skipNoTestFiles: false,
stopProcessingIfError: true
]]
])
}
}
如果测试失败,管道仍然继续。
我希望能够通过xunit设置控制管道是否继续。有没有比这更优雅的方式:
if (currentBuild.result.equals("FAILURE")) {
throw "Test results did not pass thresholds"
}
此外," stopProcessingIfError"做?我认为如果超过错误阈值但它没有停止管道。是否有一个xunit服务的参数呢?
答案 0 :(得分:1)
失败,成功和不稳定是jenkins构建状态而不是退出状态。退出状态应来自正在执行的进程。因此,如果测试失败,您的解决方案是设置exit 1
(或非零值)。您的批处理步骤似乎设置了一个退出0.检查ERRORLEVEL,因为您似乎在Windows中,如果它非零,则通过强制退出1'
注意:它可以是任何东西,但不应该是0.(我指的是退出代码中的1)