Discord Notifier
Discord Notifier provides a bridge between Jenkins and Discord through the built-in webhook functionality.
The purpose
The Jenkins Discord Webhook plugin was made to share results of a build to a Discord channel using the webhooks that Discord provides.
Through this plugin you are able to:
- Get success and fail messages about your build
- Link to build artifacts
- List SCM changes to the build
- Only send notifications on state change
Download
You'll have to manually install the plugin via the advanced tab of your plugin settings. A Jenkins plugin repo build will be available soon.
Manual Installation using Eclipse for Windows
-
Download and install Java 8 SDK from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
-
Install Eclipse IDE for Web developers
-
Download and install m2e (Maven) from http://www.eclipse.org/m2e/
-
In any File Explorer window, Right click This PC > Properties > Advanced System Settings > Environment Variables > System variables > New and add "JAVA_HOME" with path to JDK, default should lok like
C:\Program Files\Java\jdk1.8.0_181
> OK > OK > OK -
In Eclipse, Window > Prefs > Java > JREs > Edit > change to the
C:\Program Files\Java\jdk1.8.0_181
-
Create new web project > name it > provide the url of the git
-
Right-click pom.xml in the project > Run as... > Maven build.... "package"
-
It should build to success in a project subfolder called
target
. If not, google the error. File should bejenkins-discord.hpi
-
In Jenkins, Manage Jenkins > Manage Plugins > Advanced > Upload Plugin > Choose file and browse to the hpi file, then click Upload.
-
In a Project under Post-build Actions select Discord Notifier and insert webhook URL from your Discord.
Usage
This plugin uses the post-build feature to execute a request.
After installing, go to your job's configure section and add the Discord Notifier item. Then proceed to enter your webhook URL.
There are a few options you can choose from:
- Webhook URL
- The URL of the webhook (pretty self-explanatory) provided by Discord
- Send only on state change
- Checking this will only send the message when the state of the current build differs from the previous
- Advanced:
- Enable URL linking
- Enables the title, build summary and build id to be linked to the build. Requires the URL to be set in Jenkin's global configuration
- Enable artifact list
- Enables the listing of the artifacts generated by the build
- Enable version info in footer
- Adds the "Jenkins version, Discord Webhook version" text in the footer of the message
- Enable URL linking
Pipeline
Discord Notifier supports Jenkins Pipeline. The only required parameter is webhookURL (the URL of the webhook, of course) - but there isn't much point of sending nothing.
Parameters
- webhookURL (required)
- The URL of the webhook (pretty self-explanatory) provided by Discord.
- title
- The title of the embed.
- link
- If set, the title becomes a link to this URL.
- description
- The description of the message (the main chunk of text), can be markdown formatted, Markdown Text 101 (Chat Formatting: Bold, Italic, Underline).
- footer
- The text in footer of the message.
- successful
- True makes the left-hand side of the embed green, false sets it to red.
Example
pipeline {
agent any
post {
always {
discordSend description: 'Jenkins Pipeline Build', footer: 'Footer Text', link: env.BUILD_URL, successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'), title: JOB_NAME, webhookURL: 'Webhook URL'
}
}
}