0.0.2 • Published 4 years ago
simple-slack-notifier v0.0.2
Slack Notifier
A Node.js Module to send Slack messages to a specific channel.
Installation
npm install simple-slack-notifier --save
yarn add simple-slack-notifier
Usage
Javascript
const GitLabCISlackAPI = require('simple-slack-notifier');
const commitId = 'ba7b06204dfc05e140fe17e1c555169e0a1ffa30';
const token = '<Your Slack Application Token>';
const slack = new GitLabCISlackAPI();
slack.webClient(new WebClient(token)).gitlabOptions({
commitId: commitId,
projectName: '<GitLab Group>/<GitLab Project Name>',
jobId: '123456789',
gitRef: 'master',
author: 'Super Developer',
}).build();
slack.sendDeploymentStartedMessage();
slack.sendDeploymentSuccessfulMessage();
slack.sendDeploymentFailedMessage();
TypeScript
import { GitLabCISlackAPI } from 'simple-slack-notifier';
import { WebClient } from '@slack/web-api';
const commitId = '<Commit Hash>';
const token = '<Your Slack Application Token>';
const slack = new GitLabCISlackAPI();
slack.webClient(new WebClient(token)).gitlabOptions({
commitId: commitId,
projectName: '<GitLab Group>/<GitLab Project Name>',
jobId: '123456789',
gitRef: 'master',
author: 'Super Developer',
})
.channel('myslackchannel').build();
slack.sendDeploymentStartedMessage();
slack.sendDeploymentSuccessfulMessage();
slack.sendDeploymentFailedMessage();
This will send three message your Slack Channel named myslackchannel
.
Test
npm run test
Coverage
npm run coverage