-
Notifications
You must be signed in to change notification settings - Fork 248
Notifications
Andrew Bayer edited this page Nov 17, 2016
·
9 revisions
email, HipChat, slack, IRC
The post
section of a pipeline can define both where to send a notification, and on what event.
Because notifications are steps, making use of Jenkins plugins to send them is doable. In this example, using email:
post {
success {
mail to:"[email protected]", subject:"SUCCESS: ${currentBuild.fullDisplayName}", body: "Yay, we passed."
}
failure {
mail to:"[email protected]", subject:"FAILURE: ${currentBuild.fullDisplayName}", body: "Boo, we failed."
}
unstable {
mail to:"[email protected]", subject:"UNSTABLE: ${currentBuild.fullDisplayName}", body: "Huh, we're unstable."
}
changed {
mail to:"[email protected]", subject:"CHANGED: ${currentBuild.fullDisplayName}", body: "Wow, our status changed!"
}
}
There is also HipChat, Slack, IRC and more (even Yo has a notifier).
(Seriously: https://github.com/jenkinsci/notify-yo-plugin - it won't work in current form with pipeline, however, and I am not even sure if Yo still exists as an app).
You can put notifications as top-level declarations (inside pipeline
) or on a per stage
basis. For example:
pipeline {
agent any
stages {
stage('build') {
post {
success {
mail to:"[email protected]", subject:"SUCCESS: ${currentBuild.fullDisplayName}", body: "Yay."
}
}
steps {
sh 'make install'
}
}
}
}
Documentation
- Getting Started
- Running multiple steps
- Controlling your build environment
- Environment variables
- Reporting test results and storing artifacts
- Notifications
- Deployment and credentials
- Parallelism
- Triggering runs
- Parametrized pipelines
- Pipeline options and log rotation
- Jenkinsfile validation from the CLI
- Advanced pipeline authoring
- Syntax reference
- Version history and changes
Examples