Skip to content

Instantly share code, notes, and snippets.

@lvthillo
Created March 19, 2018 17:56
Show Gist options
  • Save lvthillo/496a7c660f1571046f8cb7e390bb5b5f to your computer and use it in GitHub Desktop.
Save lvthillo/496a7c660f1571046f8cb7e390bb5b5f to your computer and use it in GitHub Desktop.
Groovy function used in Jenkins pipeline to publish build result to Slack
#!/usr/bin/env groovy
def call(String buildResult) {
if ( buildResult == "SUCCESS" ) {
slackSend color: "good", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was successful"
}
else if( buildResult == "FAILURE" ) {
slackSend color: "danger", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was failed"
}
else if( buildResult == "UNSTABLE" ) {
slackSend color: "warning", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was unstable"
}
else {
slackSend color: "danger", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} its resulat was unclear"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment