Created
August 21, 2017 10:41
-
-
Save ntakouris/2a23600cf6576c49c7df41ecec67dfe4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def notifyBuild(String buildStatus = 'STARTED') { | |
// build status of null means successful | |
buildStatus = buildStatus ?: 'SUCCESSFUL' | |
// Default values | |
def colorName = 'RED' | |
def colorCode = '#FF0000' | |
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'" | |
def summary = "${subject} ${env.BUILD_URL}" | |
// Override default values based on build status | |
if (buildStatus == 'STARTED') { | |
color = 'YELLOW' | |
colorCode = '#FFFF00' | |
} else if (buildStatus == 'SUCCESSFUL') { | |
color = 'GREEN' | |
colorCode = '#00FF00' | |
} else { | |
color = 'RED' | |
colorCode = '#FF0000' | |
} | |
// Send notifications | |
slackSend (color: colorCode, message: summary) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment