pipeline {
agent any
//stages
post {
always {
sendNotification(currentBuild.result)
}
success {
echo 'Build was a success'
}
failure {
echo 'Build failure'
}
changed {
echo 'Build status changed.'
}
}
}//end pipeline
def sendNotification(buildStatus) {
buildStatus = buildStatus ?: 'SUCCESSFUL'
def color = buildStatus == 'SUCCESSFUL' ? 'good' : 'danger'
def message = "${currentBuild.fullDisplayName} *${buildStatus}*. (<${env.BUILD_URL}|Open>)"
slackSend (channel: '#builds', color: color, message: message)
}