def notify_success() { slackSend color: "good", message: "${env.JOB_NAME} #${env.BUILD_NUMBER} succeeded! (<${env.RUN_DISPLAY_URL}|Open>)" } def notify_failure() { slackSend color: "danger", message: "${env.JOB_NAME} #${env.BUILD_NUMBER} failed! Check the status (<${env.RUN_DISPLAY_URL}|here>)." } pipeline { agent any stages { stage('first test'){ steps{ ... } } stage('testing'){ steps{ ... if (currentBuild.result == "SUCCESS") { notify_success() } else { notify_failure() } } } } }