A simple Groovy script which enables Flowdock notifications to be sent from a Jenkins Pipeline. The current Flowdock notification plugin does not have any Pipeline integration--here is a stopgap.
Inspired by and lifted from this thread and this comment specifically.
The following must be available in your Jenkins installation to use this library:
- Pipeline plugins, of course
- Pipeline: Shared Groovy Libraries plugin
- An appropriate source code management plugin supported by the above, probably the GitHub Branch Source plugin
A Jenkins administrator must install the library as follows:
- In Manage Jenkins => Configure System, find the Global Pipeline Libraries section.
- Click on Add.
- Specify:
- Name:
flowdock-notifier
- Default version:
master
- For retrieval method, assuming GitHub, select Modern SCM and then GitHub:
- Owner:
c3tp
- Repository:
jenkins-flowdock-notifier
- Click Save at the bottom.
You must declare use of the library somewhere before use:
library 'flowdock-notifier'
Then, call flowdockNotify
in an appropriate place in your pipeline. It needs to be a step-class block, including and probably most appropriately a post block. There are three arguments:
this
- passes the script object to the notifier function to provide necessary context- API token for Flowdock. This can be retrieved from your Flowdock profile page
- A string containing list of tags (optional).
For example:
library 'flowdock-notifier'
pipeline {
agent any
stages {
stage('Example') {
steps {
echo 'Hello World'
sh '/bin/false'
}
}
}
post {
changed {
flowdockNotify this,'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '#test'
}
}
}