Slack Notifications for main branch only

Hi

I am trying to ensure that if our build fails we get notified by slack BUT only for our main branch.
Here is our code for the slack notification:

hooks:
  on_fail:
    steps:
      notify:
        image: codefresh/slacknotifier
        environment:
          - SLACK_HOOK_URL=<webhook url>
          - SLACK_ATTACHMENTS=<slack message>
      when:
        branch:
          only:
            - /^(main)/i

At the minute it is still slacking for feature branches. Any assistance would be greatly appreciated.

Hello

I am not sure if that the regex is correct. Can you please try /^((main)$).*/g or maybe just main on its own?

Do you have other branches that contain the word main?

Hi

This is the whole thing. I only shared a snippet.

  • /^(main|release.*[0-9]+.[0-9]+)/i

Hello

I don’t see any obvious problem with the regex.

Please open an issue with us (from the top right menu in the Codefresh UI) and our support team will investigate. Remember to include the URL of a build that has the issue.

No problem thank you