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. and https://github.com/c3tp/jenkins-flowdock-notifier
The following must be available in your Jenkins installation to use this library:
- Pipeline plugins, of course
- Pipeline: Shared Groovy Libraries plugin
- HTTP Reuqest Plugin 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:
enhanced-flowdock-notifier
- Default version:
master
- For retrieval method, select Modern SCM and then GitLab:
- Owner:
eeddir
- Repository:
enhanced-flowdock-pipeline
- Click Save at the bottom.
You must declare use of the library somewhere before use:
library 'enhanced-flowdock-notifier'
Then, call enhancedFlowdockNotify
in an appropriate place in your pipeline. It needs to be a step-class block. There are four 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).
- An parameter indicating whether a chat notification shall be sent for a successful build (SEND_CHAT_FOR_SUCCESS, default), or not (NO_CHAT_FOR_SUCCESS)
For example:
pipeline {
//...
stage('Flowdock Notifier') {
library 'enhanced-flowdock-notifier'
enhancedFlowdockNotify this,'token', '#test', 'NO_CHAT_FOR_SUCCESS'
}
}