| always | 无论成败都执行 |
|---|---|
| failure | 收集诊断与通知 |
| cleanup | 最后执行,适合删临时资源 |
| 作用域 | 阶段级与流水线级都可用 |
失败收集与清理
失败收集与清理
post {
always {
junit 'reports/*.xml', allowEmptyResults: true
}
failure {
sh 'collect-diagnostics.sh || true'
}
cleanup {
deleteDir()
}
}诊断收集加 || true:收集脚本自身失败不应再叠加一次失败。