Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion notifier/orb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1
description: "Tools for notifying external services about CI events"

orbs:
slack: circleci/slack@5.2.3
slack: circleci/slack@6.0.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Upgrading the circleci/slack orb to version 6.0.0 introduces a breaking change that will cause the slack-on-fail command to fail.

In v6.0.0, the custom parameter of the slack/notify command no longer accepts a raw JSON string. Instead, it requires a path to a file containing the JSON payload.

To fix this, you need to modify the slack-on-fail command (defined on lines 17-95) to first write the custom JSON payload to a file, and then pass the path to that file to the slack/notify command.

Here is an example of how you could modify the steps in the slack-on-fail command:

    steps:
      - run:
          name: install curl
          command: |
            if which curl >/dev/null; then
              exit 0
            elif which apk >/dev/null; then
              apk add --no-cache --no-progress curl curl-dev
            elif which apt-get >/dev/null; then
              apt-get update -qy
              apt-get install -qy curl
            else
              echo >&2 "ERROR: could not find supported package manager"
              exit 1
            fi
      - run:
          name: Create custom slack message for failed job
          command: |
            cat <<'EOF' > /tmp/slack_fail_template.json
            {
              "blocks": [
                {
                  "type": "header",
                  "text": {
                    "type": "plain_text",
                    "text": "Job Failed :x:",
                    "emoji": true
                  }
                },
                {
                  "type": "section",
                  "fields": [
                    {
                      "type": "mrkdwn",
                      "text": "Job name: `${CIRCLE_JOB}`"
                    },
                    {
                      "type": "mrkdwn",
                      "text": "Repository name: `${CIRCLE_PROJECT_REPONAME}`"
                    },
                    {
                      "type": "mrkdwn",
                      "text": "Branch `${CIRCLE_BRANCH}`"
                    },
                    {
                      "type": "mrkdwn",
                      "text": "Blame :point_right: @${CIRCLE_USERNAME}"
                    }
                  ]
                },
                {
                  "type": "actions",
                  "elements": [
                    {
                      "type": "button",
                      "text": {
                        "type": "plain_text",
                        "text": "View Job"
                      },
                      "url": "${CIRCLE_BUILD_URL}"
                    }
                  ]
                }
              ]
            }
            EOF
      - slack/notify:
          channel: <<parameters.channel>>
          event: fail
          custom: /tmp/slack_fail_template.json

This change preserves the install curl step, adds a new step to create the JSON template file, and updates the slack/notify call to use this file. The empty text field from the original JSON has been removed as it's not necessary when using blocks.


executors:
alpine-latest:
Expand Down