How to customize your Slack messages when using CircleCI's Slack Orb

 

Users often times would like to customize Slack messages to represent CircleCI and include important build information. Below is a template using markdown to get you started.

You can also change the name of your slack bot user to "CircleCI". You can do this by navigating to https://api.slack.com/apps/ > your app > Display Information > App name

You can update you app icon to include a CircleCI logo. You can find CircleCI logos and Icons here: https://brandfolder.com/circleci

 

Example Slack Notification with Custom message: 

     
- slack/notify:
          event: fail
          custom: | 
            {
                "blocks": [
                    {
                        "type": "section",
                        "text": {
                            "type": "mrkdwn",
                            "text": "Failed: $CIRCLE_USERNAME's build of \n<$CIRCLE_BUILD_URL|$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME>\n(<https://app.circleci.com/pipelines/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME?branch=$CIRCLE_BRANCH|$CIRCLE_BRANCH>) \n- <$CIRCLE_BUILD_URL|$CIRCLE_JOB> failed" 
                        }
                    }
                ]
            }  

You might also find it useful to use one of CircleCI's pre-built message templates which you can find here. Additionally, you can find the source code to these pre-build message templates here:  https://github.com/CircleCI-Public/slack-orb/tree/master/src/message_templates

You can build your own custom templates using Slack's BlocK Kit Builder .

Note: The above solution is valid for Slack Orb Version 4.1.1

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.