Send slack message only on failed build

How do I set a slack set up to only send the message when a build fails?

1 Like

Hi @bryce-ifit,

You can run any step on build failure using a run_if expression in YML mode. Related docs: http://devcenter.bitrise.io/tips-and-tricks/disable-a-step-by-condition/#run-a-step-only-if-the-build-failed

E.g. for Slack step:

    - slack:
        is_always_run: true
        run_if: .IsBuildFailed

with this configuration this Slack step will only run if .IsBuildFailed is true, which is only true in case if a previous step failed.

If you have any questions just let us know! :wink:

P.S.: in case of the Slack step is_always_run: true is optional as thatโ€™s the default value for the Slack step (https://github.com/bitrise-io/steps-slack-message/blob/75c5e8b40c311afcd60934393514093e3fed2b4d/step.yml#L23). For other steps this is usually required. For more info see the linked DevCenter guide (http://devcenter.bitrise.io/tips-and-tricks/disable-a-step-by-condition/#run-a-step-only-if-the-build-failed).

4 Likes

Great, thank you!

1 Like

Any time :wink: