我有一个如下所示的声明性管道阶段,
stage('build') {
steps {
echo currentBuild.result
script {
try {
bat 'ant -f xyz\\build.xml'
} catch (err) {
echo "Caught: ${err}"
currentBuild.result = 'FAILURE'
}
}
echo currentBuild.result
}
}
我预计管道会失败,因为构建失败并显示以下消息。
BUILD FAILED
C:\...\build.xml:8: The following error occurred while executing this line:
C:\...\build.xml:156: The following error occurred while executing this line:
C:\...\build.xml:111: Problem creating jar: C:\...\xyz.war (The system cannot find the path specified) (and the archive is probably corrupt but I could not delete it)
currentBuild.result 在我打印时都是空的。
蚂蚁叫错了吗?
为什么管道没有自动捕获返回状态?
蚂蚁调用不会返回失败状态吗?
我尝试了 catchError 而不是 try..catch ,但仍然没有捕获到构建失败。
catchError {
bat 'ant -f xyz\\build.xml'
}