Skip to content

joyarzun/jenkins-slack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jenkins Slack Notificator

Allow notifications to Slack from Jenkins with a simple Webhook

Message

In advance: The image is just referential :p

Installation

npm install jenkins-slack --save

Usage

const App = require("jenkins-slack");
const config = {
  port: 8080
  token: "xoxb-XXXXXXXXX",
  channel: "XXXXXXXXX" //channel id, not name
};

const app = App(config);

Then, go to your job, configure, and in Job Notifications like: Job Notifications

The next parameters can be customized in config object:

{
  route: "/slack-notification",
  port: 8080,
  processBody: body => ({
    name: body.name,
    url: body.build.full_url,
    status: body.build.status,
    scm: body.build.scm
  }),
  slackPostMessageUrl: "https://slack.com/api/chat.postMessage",
  textFormat: data =>
    `The job \`${data.name}\` has finished\nStatus: \`${data.status}\``
}

How to get token and channel

To get a token you can use your own or create an app https://api.slack.com/apps

To obtain channel id you can go to https://api.slack.com/methods/channels.list/test and get a list of channels.

Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

About

Jenkins notifications for slack

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published