Giter Site home page Giter Site logo

slack-plugin's Introduction

Slack plugin for Jenkins

  • Stability: Build Status
  • Slack: Slack Signup (click to sign up)

Provides Jenkins notification integration with Slack or Slack compatible applications like RocketChat and Mattermost.

Install Instructions for Slack

  1. Get a Slack account: https://slack.com/
  2. Configure the Jenkins integration: https://my.slack.com/services/new/jenkins-ci
  3. Install this plugin on your Jenkins server.
  4. Configure it in your Jenkins job (and optionally as global configuration) and add it as a Post-build action.

Install Instructions for Slack compatible application

  1. Log into Slack compatible application.
  2. Create a Webhook (it may need to be enabled in system console) by visiting Integrations.
  3. You should now have a URL with a token. Something like https://mydomain.com/hooks/xxxx where xxxx is the integration token and https://mydomain.com/hooks/ is the Base URL.
  4. Install this plugin on your Jenkins server.
  5. Configure it in your Jenkins job (and optionally as global configuration) and add it as a Post-build action.

Security

Use Jenkins Credentials and a credential ID to configure the Slack integration token. It is a security risk to expose your integration token using the previous Integration Token setting.

Create a new Secret text credential:

image

Select that credential as the value for the Integration Token Credential ID field:

image

Bot user option

This plugin supports sending notifications via bot users. You can enable bot user support from both global and project configurations. If the notification will be sent to a user via direct message, default integration sends it via @slackbot, you can use this option if you want to send messages via a bot user. You need to provide credentials of the bot user for integration token credentials to use this feature.

Bot user option is not supported, if you use Base Url for a Slack compatible application.

Jenkins Pipeline Support

Includes Jenkins Pipeline support as of version 2.0:

slackSend color: 'good', message: 'Message from Jenkins Pipeline'

Additionally you can pass a JSONArray as a String in order to send complex messages, as per the example:

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
node {
    JSONArray attachments = new JSONArray();
    JSONObject attachment = new JSONObject();

    attachment.put('text','I find your lack of faith disturbing!');
    attachment.put('fallback','Hey, Vader seems to be mad at you.');
    attachment.put('color','#ff0000');

    attachments.add(attachment);
    slackSend(color: '#00FF00', channel: '@gustavo.maia', attachments: attachments.toString())
}

For more information about slack messages see Slack Messages Api and Slack attachments Api

Developer instructions

Install Maven and JDK.

$ mvn -version | grep -v home
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Java version: 1.7.0_79, vendor: Oracle Corporation
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-65-generic", arch: "amd64", family: "unix"

Run unit tests

mvn test

Create an HPI file to install in Jenkins (HPI file will be in target/slack.hpi).

mvn clean package

slack-plugin's People

Contributors

ahippo avatar batmat avatar bigwheel avatar dave-miles avatar derinbay avatar dpires avatar fgs-dbudwin avatar grantmd avatar gricey432 avatar gurumaia avatar hsatac avatar idserda avatar kei-yamazaki avatar kmadel avatar mtyurt avatar ndeloof avatar owenscode avatar peergum avatar philowest avatar randomsync avatar reamer avatar samrocketman avatar schisamo avatar sergk8 avatar shahp00ja avatar sheehan avatar tbartley avatar timp21337 avatar ydubreuil avatar yestin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.