Last active
September 19, 2018 07:27
-
-
Save yutsengwei/6afbe0c118ac393a5f40c5e6b76352c6 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
| pipeline { | |
| parameters { | |
| string(name: 'SLACK_CHANNEL_TOKEN_CREDENTIAL', | |
| description: 'Default Slack token credential', | |
| defaultValue: 'your-token-credential') | |
| string(name: 'SLACK_CHANNEL_BASEURL', | |
| description: 'Default Slack base url', | |
| defaultValue: 'your-slack-base-url') | |
| string(name: 'SLACK_CHANNEL', | |
| description: 'Default Slack channel to send messages to', | |
| defaultValue: '#your-slack-channel-name') | |
| } | |
| stages { | |
| .... | |
| } | |
| post { | |
| aborted { | |
| slackSend baseUrl: "${params.SLACK_CHANNEL_BASEURL}", botUser: true, channel: "${params.SLACK_CHANNEL}", color: 'warning', failOnError: true, message: "*ABORTED:*: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})", tokenCredentialId: "${params.SLACK_CHANNEL_TOKEN_CREDENTIAL}" | |
| } // aborted | |
| failure { | |
| slackSend baseUrl: "${params.SLACK_CHANNEL_BASEURL}", botUser: true, channel: "${params.SLACK_CHANNEL}", color: 'danger', failOnError: true, message: "*FAILED:* Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})", tokenCredentialId: "${params.SLACK_CHANNEL_TOKEN_CREDENTIAL}" | |
| } // failure | |
| success { | |
| slackSend baseUrl: "${params.SLACK_CHANNEL_BASEURL}", botUser: true, channel: "${params.SLACK_CHANNEL}", color: 'good', failOnError: true, message: "*SUCCESS:*: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})", tokenCredentialId: "${params.SLACK_CHANNEL_TOKEN_CREDENTIAL}" | |
| } // success | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment