Git Product home page Git Product logo

slack-orb's Introduction

Slack Orb

Easily integrate custom Slack notifications into your CircleCI projects. Create custom alert messages for any job or receive status updates.

Learn more about orbs.

Usage

Example config:

orbs:
  slack: circleci/[email protected]

jobs:
  build:
    docker:
      - image: <docker image>
    steps:
      - slack/<command>

[email protected] from the circleci namespace is imported into slack which can then be referenced in a step in any job you require.

Commands

  • Notify

Usage slack/notify
Description: Notify a slack channel with a custom message
Parameters: - webhook: Enter either your Webhook value or use the CircleCI UI to add your token under the SLACK_WEBHOOK environment variable

- message: Enter your custom message to send to your Slack channel.

- mentions: A comma separated list of Slack user IDs. example 'USER1,USER2,USER3'. Note, these are Slack User IDs, not usernames. The user ID can be found on the user's profile.

- color: Color can be set for a notification to help differentiate alerts.

Example:

jobs:
  alertme:
    docker:
      - image: circleci/node
    steps:
      - slack/notify:
            message: "This is a custom message notification" #Enter your own message
            mentions: "USERID1,USERID2" #Enter the Slack IDs of any users who should be alerted to this message.
            color: "#42e2f4" #Assign custom colors for each notification
            webhook: "webhook" #Enter a specific webhook here or the default will use $SLACK_WEBHOOK

Custom Message Example

See Slack's Basic message formatting documentation for guidance on formatting notification messages.

  • Status

Usage slack/status
Description: Send a status alert at the end of a job based on success or failure. Must be last step in job
Parameters: - webhook: Enter either your Webhook value or use the CircleCI UI to add your token under the SLACK_WEBHOOK environment variable

- fail_only: false by default. If set to `true, successful jobs will not send alerts

- mentions: A comma separated list of Slack user IDs. example 'USER1,USER2,USER3'. Note, these are Slack User IDs, not usernames. The user ID can be found on the user's profile.

Example:

jobs:
  alertme:
    docker:
      - image: circleci/node
    steps:
      - slack/status:
            mentions: "USERID1,USERID2" #Enter the Slack IDs of any users who should be alerted to this message.
            fail_only: "true" #Optional: if set to "true" then only failure messages will occur.
            webhook: "webhook" #Enter a specific webhook here or the default will use $SLACK_WEBHOOK

Status Success Example Status Fail Example

Help

How to get your Slack Webhook: Full instructions can be found at Slack: https://api.slack.com/incoming-webhooks

  1. Create Slack App. This will also be the name of the "user" that posts alerts to Slack. You'll be asked for which Workspace this app belongs to.
  2. In the settings for the app, enable Incoming Webhooks
  3. In the left hand panel of your Slack app settings, under Features click Incoming Webhooks
  4. Click Add New Webhook to Workspace. You will be asked to pick a channel for the webhook here.
  5. Done! A webhook URL will be created.

What to do with Slack Webhook: You can implement the Webhook in one of two ways, as an environment variable, or as a parameter.

  1. In the settings page for your project on CircleCI, click Environment Variables. From that page you can click the Add Variable button. Finally, enter your webhook as the value, and SLACK_WEBHOOK as the name.
  2. You can enter the Webhook for the individual status or alert by entering is at the webhook parameter, as shown above.

slack-orb's People

Contributors

iynere avatar kyletryon avatar

Watchers

 avatar  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.