问题在于,在声明式的post部分中,currentBuild.result未设置为SUCCESS。虽然设置了FAILURE和ABORTED。因此,此刻的行为目前似乎不一致。
我改进了如何为Jenkins管道获得相同的Mailer行为以更好地处理这种情况的答案:
pipeline { agent any stages { stage('test') { steps { echo 'some steps' // error("Throw exception for testing purpose..") } } } post { always { script { if (currentBuild.result == null) { currentBuild.result = 'SUCCESS' } } step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "test@test.com", sendToIndividuals: true]) } }}


