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.
NOTE: Flowdock inbox push api is depreciated
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
- Application created and integrated with the flow on flowdock you want to send notifications too. See below for more info.
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 contexttype
- tells the script if you want a flow message or inbox message. Only accepts stringmessage
orinbox
- A sources API Flow Token.
- A string containing list of tags (optional).
For example:
library 'flowdock-notifier'
pipeline {
// ...
post {
changed {
flowdockNotify this, 'type', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '#test'
}
}
}
More info:
In order to get a flow_token to a source, you will need to create an application.
- Sources: https://www.flowdock.com/api/authentication#source-token
- Creating an application: https://www.flowdock.com/oauth/applications