[英]Jenkins pipeline not failing based on batch exit code
I am having trouble with a Jenkins pipeline that is not failing when a called batch file fails. 我遇到了Jenkins管道问题,该管道在被调用的批处理文件失败时不会失败。 I have checked the batch file, it returns a non-zero status code, but somehow this seems to be not considered.
我已经检查了批处理文件,它返回了非零的状态代码,但是似乎不考虑这一点。 Does anyone of you have a hint for me?
你们中有人对我有暗示吗?
desired pipeline 所需管道
node {
stage('1'){
dir('_src') {
bat 'call test.bat'
}
}
}
Calling the batch in cmd window results in the following 在cmd窗口中调用批处理将导致以下结果
>call test.bat
INFO: Started ...
ERROR
Press any key to continue . . .
>echo %ERRORLEVEL%
2
I also used the following pipeline for testing 我还使用了以下管道进行测试
node {
stage('1'){
dir('_src') {
bat '''call test.bat
echo %ERRORLEVEL%'''
}
}
}
... with this output ...此输出
C:\_src>call test.bat
INFO: Started ...
ERROR
Press any key to continue . . .
2
Still, the pipeline is not failing. 尽管如此,管道并没有失败。 Any ideas?
有任何想法吗?
It should be: 它应该是:
node {
stage('1'){
dir('_src') {
bat '''call test.bat
exit %ERRORLEVEL%'''
}
}
}
You only write an echo, not actually doing a return/ exit. 您仅编写回显,而没有实际执行返回/退出。 Try to add a concrete
Exit 0
or in your case Exit 2
in your script. 尝试在脚本中添加具体的
Exit 0
或您的情况下的Exit 2
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.