Awesome
gradle-slack-plugin
Gradle plugin to send Slack messages according to your build lifecycle. Useful to integrate with a CI server, to notify everyone that some gradle task has failed.
Usage
The plugin is available in JitPack. Just add the following to your buildscript dependencies:
buildscript {
repositories {
....
maven {
url "https://jitpack.io"
}
}
dependencies {
...
classpath 'com.github.Mindera:gradle-slack-plugin:1.0.7'
}
}
Apply it:
apply plugin: 'com.mindera.gradle.slack'
Configuration
First you need to setup slack to receive incoming messages:
- Go to your_team.slack.com/services/new/incoming-webhook
- Press Add Incoming WebHooks Integration
- Grab your WebHook URL
Then in your build.gradle file:
slack {
url 'your WebHook URL'
}
By default, everytime a build fails a slack message will be sent to the channel you configured. If a build succeeds nothing happens.
There are more optional fields that enable you to configure the slack integration:
slack {
url 'your WebHook URL'
dependsOnTasks 'testDebug', 'publishApkRelease'
title 'my app name'
enabled = isCDMachine()
}
- dependsOnTasks: let you specify a list of tasks that will trigger a message to slack, in case of error and success;
- title: the title of the slack message, can be the name of your app for instance;
- enabled: a boolean to define if the slack integration is active or not, useful to avoid sending messages on your local builds.
Credits
Slack WebHook Java API by gpedro
License
gradle-slack-plugin is available under the MIT license. See the LICENSE file for more info.