I already used the following declarative script as a part of my cleanup script, now I should convert it to the scripted pipeline, how I can convert the post to the scripted pipeline?
The scripted equivalent to the declarative
steps {
// pipeline steps here
post {
failure {
// failure handler here
}
success {
// success handler here
}
always {
// always handler here
}
}
is the native Groovy try { } catch { }
:
try {
// pipeline steps here
// success handler here
} catch(Exception e) {
// failure handler here
} finally {
// always handler here
}
I'm not sure off the top of my head how to add an abort handler, but I think you might be able to do it by inspecting the currentBuild.result
variable in the failure handler block.