Integrate CircleCI with Slack for Notifications.

version: 2.1orbs:
heroku: circleci/heroku@0.0.10
slack: circleci/slack@4.1
jobs:
build:
docker:
- image: circleci/node:10.16.3
working_directory: ~/search-yc-top-companies
steps:
- checkout
# install dependencies
- run:
name: Install Dependencies
command: npm install
- run:
name: Build
command: npm run build
status:
docker:
- image: cimg/base:stable
steps:
- run: echo "Sending status"
- slack/notify:
event: fail
template: basic_fail_1
- slack/notify:
event: pass
template: success_tagged_deploy_1
workflows:
heroku_deploy:
jobs:
- build
- heroku/deploy-via-git: # Use the pre-configured job, deploy-via-git
requires:
- build
filters:
branches:
only: master
- status:
requires:
- build
- heroku/deploy-via-git
  • Go to Slack Apps.
  • Click on Create New App and then From Scratch.
  • Give a name to your Slack app and select your workspace.
  • Select Bots in Add features and functionality .
  • Next, click on Review scopes to add and go to the Scopes section and under that Add permissions for your Bot Token Scopes.
  • Add chat:write , users:write permissions.
  • Now scroll up to section OAuth Tokens for Your Workspace and there you’ll see Bot User OAuth token, this we’ll be using as Access token so copy it.
  • After that go back to Basic Information under Settings on the left menu.
  • Install the App into your workspace.
  • Go to Project Settings and Click Environment Variables
  • Add SLACK_DEFAULT_TOKEN as name and access token as value.
  • Next, add SLACK_DEFAULT_CHANNEL as name and channel Id
  • Go back to the project and Run the Pipeline manually or trigger it by pushing a change to your Github repo.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pankaj Thakur

Pankaj Thakur

Software Developer and love to build things.