Check if last build failed/status changed (e.g. only Slack notify if build failed or fixed)

Currently we notify Slack on build failures only but we’d like to see when the build gets fixed. We don’t want to see every successful build, though, as it’s not useful information when it’s just repetitive.

Great idea, thanks for creating the #feature-request here @rajit! :wink:

1 Like

I agree, our Slack channel gets spammed with successful builds.

@magnus80a you can send a Slack message only about failed builds. For that see: http://devcenter.bitrise.io/tips-and-tricks/disable-a-step-by-condition/#run-a-step-only-if-the-build-failed

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

I assume from this feature request that it isn’t possible to limit Slack notifications to only send on failure or first success. Is that correct?

It seems to be possible by using Bitrise API in the step prior to Slack notify.
E.g. figure out status of the previous build, export environment variable and enable Slack notify step conditionally.

1 Like

It definitely is possible to send only in case of failure. What’s not possible directly is to only send when the status changes (e.g. only when previous build failed, new one succeeded). For that you can do something like what @koral mentioned above (Check if last build failed/status changed (e.g. only Slack notify if build failed or fixed) - #6 by koral)

Same problem here, consider this a +1

Hi @gcamp,

Please click the vote button at the top if you want to bump the feature request’s priority! :wink:

+1

We have a few people on the team. We are interested in getting Slack message in our team’s channel whenever build fails and then when it becomes green again. There is no value for us in having repetitive messages that the build has passed every time someone pushes.

Thanks in advance!

1 Like

We are planning to create the step for this purpose which will work like the following example flow:
Example usage:

  • run this step, exported env: PREVIOUS_BUILD_STATUS=failed, BUILD_STATUS_CHANGED=true (at this point the current build is still successful)

  • cache-pull step run_if: ‘{{enveq “PREVIOUS_BUILD_STATUS” “success”}}’ (downloads cache if the previous build was successful only)

  • run other tasks…

  • slack run_if: {{enveq “PREVIOUS_BUILD_STATUS” “failed” | and (not .IsBuildFailed)}} (send message about builds turning to green)

  • slack run_if: {{enveq “PREVIOUS_BUILD_STATUS” “success” | and .IsBuildFailed}} (send message about builds turning to failed)

  • run this step, exported env: PREVIOUS_BUILD_STATUS=failed, BUILD_STATUS_CHANGED=true (at this point the current build might be failed or successful, set true or false accordingly)

  • slack run_if: {{enveq “BUILD_STATUS_CHANGED” “true”}} (send message about build status has changed)

I think this would cover all the requests in the previous comments. Let us know WDYT. :rocket:

3 Likes

The step will be released within minutes: https://github.com/bitrise-steplib/bitrise-step-build-status-change/releases/tag/0.1.1

2 Likes

It looks like it works flawlessly, thanks! :smiley:

Closing this feature request as the step provides a solution for this problem now.

Thanks everyone for the request, for commenting/sharing information and for voting :slight_smile:

1 Like