[英]Jenkins build gets failed, when unit test cases are failed
Jenkins build gets failed, when unit test cases are failed, Here am using pipeline script in jenkins, Need to generate HTML report using mocha-awesome, I can get the HTML report only when all test cases are passed, Build fails if any functions failed in my testcases. Jenkins构建失败,当单元测试用例失败时,这里在jenkins中使用管道脚本,需要使用mocha-awesome生成HTML报告,我只能在所有测试用例通过后才能获取HTML报告,如果任何功能失败,构建就会失败在我的测试用例中。 Here you can see the screenshot
在这里您可以看到屏幕截图
The call to the unit test run returns with exit status 1
. 单元测试运行的调用以退出状态
1
返回。 What you can do is use the returnStatus
option for the sh
or bat
step which will then not fail the build itself but leaves that up to you: 您可以做的是在
sh
或bat
步骤中使用returnStatus
选项,这将不会使构建本身失败,而是由您自己决定:
def exitStatus = sh returnStatus: true, script: 'unittests'
or: 要么:
def exitStatus = bat returnStatus: true, script: 'unittests.exe'
Having this you can selectively fail the build, ie if exitStatus == 1
then ignore as it signals a test fail, if it is anything but 0
or 1
then fail the build using the error
step. 有了这个,您可以有选择地使构建失败,即,如果
exitStatus == 1
则忽略它,因为它表示测试失败;如果它不是0
或1
则使用error
步骤使构建失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.