Process Flow - Slack notifications
Jenkins Job Starts
Build Executes
Check Build Result
Send Slack
Success Msg
Notification Sent
Jenkins runs a job, checks if it succeeded or failed, then sends a Slack message accordingly.
pipeline {
agent any
stages {
stage('Build') {
steps { echo 'Building...' }
}
}
post {
success { slackSend channel: '#general', message: 'Build succeeded!' }
failure { slackSend channel: '#general', message: 'Build failed!' }
}
}| Step | Build Status | Action | Slack Message | Notification Sent |
|---|---|---|---|---|
| 1 | N/A | Start build | N/A | No |
| 2 | Running | Execute build steps | N/A | No |
| 3 | Success | Check post conditions | Build succeeded! | Yes |
| 4 | End | Finish pipeline | N/A | No further notifications |
| Variable | Start | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|
| buildStatus | N/A | Running | Success | Success |
| slackMessage | N/A | N/A | Build succeeded! | Build succeeded! |
| notificationSent | No | No | Yes | Yes |
Jenkins Slack Notifications: - Use 'post' section in pipeline for notifications - 'success' and 'failure' blocks send messages - Use slackSend step with channel and message - Notifications happen after build completes - Customize messages per build result