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

step
🗓-planned
#1

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.

0 Likes

#2

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

1 Like

#3

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

0 Likes

#4

@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:

0 Likes

#5

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?

0 Likes

#6

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

#7

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))

0 Likes

#8

Same problem here, consider this a +1

0 Likes

#9

Hi @gcamp,

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

0 Likes

#10

+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

#11

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:

0 Likes