Skip to content
Kyle T edited this page Sep 30, 2020 · 8 revisions

PREVIEW

This wiki is a preview for Slack orb version 4.0.0, due to release October 12th 2020

Slack Orb For CircleCI

Easily send customized Slack notifications as a part of your CI/CD pipeline, using rich templates.

What are Orbs?

Usage

The Slack orb makes use of OAuth to post messages to your Slack workspace. Follow our setup guide for authenticating with Slack.

For full usage guidelines, see the orb registry listing.

Templates

The Slack Orb comes with a number of included templates to get your started with minimal setup. Feel free to use an included template or create your own.

Template Preview Template Description
basic fail basic_fail_1 Should be used with the "fail" event.
successful tagged deploy success_tagged_deploy_1 To be used in the event of a successful deployment job. see orb usage examples
basic on hold basic_on_hold_1 To be used in the on-hold job. see orb usage examples

Custom Message Template

  1. Open the Slack Block Kit Builder: https://app.slack.com/block-kit-builder/
  2. Design your desired notification message.
  3. Replace any placeholder values with $ENV environment variable strings.
  4. Set the resulting code as the value for your custom parameter.
- slack/notify:
    event: always
    custom: |
      {
        "blocks": [
          {
            "type": "section",
            "fields": [
              {
                "type": "plain_text",
                "text": "*This is a text notification*",
                "emoji": true
              }
            ]
          }
        ]
      }

Branch Filtering

Limit Slack notifications to particular branches with the "branch_pattern" parameter.

A comma separated list of regex matchable branch names. Notifications will only be sent if sent from a job from these branches. By default ".+" will be used to match all branches. Pattern must match the full string, no partial matches.

See usage examples.

FAQ

Q: How can I stop duplicate messages in parallel jobs?

A: It is not possible to limit the output to a singular output. The notify command acts as a convenient and parametrizable way to send a curl request to the provided Slack WebHook. When a job is ran in parallel, each instance runs independently and sends its own notification.


Q: Is it possible to receive only the final status of the Workflow?

A: Each job within a workflow operates independently, as the orb code executes within each job, they are not able to report on the outcome of the workflow after all jobs have completed. Each job can independently report its individual status.


Q: How do I use custom environment variables?

A: Each step executes as a separate shell. To export environment variables for use in over steps, they must be added to BASH_ENV. View Using Environment Variables and the included usage examples.


Q: Can other orbs use this Slack Orb?

A: If you would like to integrate with this orb from your own orb or service, we recommend hacking your orb generate a template.json file containing the payload of your desired message and saving the destination to an environment variable. Make sure to export the environment variable to $BASH_ENV. The user can the select the environment variable created as the template for the Slack Orb notification.


Clone this wiki locally