I am trying to send Success/Failure notifications to slack channel but I am not entering the else if clause? can someone please help me here?
post {
always {
cleanWs(deleteDirs: true)
deleteDir()
}
success {
script {
if (params.OPERATION != 'Refresh' && params.ENV != 'select') {
wrap([$class: 'BuildUser']) {
slackSend channel: '#build-infra', color: 'good', "Job Name: ${JOB_BASE_NAME}\nStatus: Successful"
}
} else if (params.OPERATION == 'Destroy') {
wrap([$class: 'BuildUser']) {
slackSend channel: '#build-infra', color: '#FFFF00', "Job Name: ${JOB_BASE_NAME}\nStatus: Successful"
}
}
}
}
failure {
script {
if (params.OPERATION != 'Refresh' && params.ENV != 'select') {
wrap([$class: 'BuildUser']) {
slackSend channel: '#build-infra', color: 'danger', message: "Job Name: ${JOB_BASE_NAME}\nStatus: Failed"
}
} else if (params.OPERATION == 'Destroy') {
wrap([$class: 'BuildUser']) {
slackSend channel: '#build-infra', color: '#ff6d2b', message: "Job Name: ${JOB_BASE_NAME}\nStatus: Failed"
}
}
}
}
}