Home
Support Forums

Don't generate Slack fail notifications for cancelled builds

We have a monorepo that contains the source code for out LAMP based CMS as well as our statically generating public site. When a commit only affects the CMS, we prevent the site from re-deploying with this config in our netlify.toml:

ignore = "git diff --quiet HEAD^ HEAD ../library ../netlify.toml ../yarn.lock"

This works great. However, our Netlify-powered Slack notification for “Deploy failed” still fires when the build is “cancelled” because of this ignore rule.

An option to not fire the failed notification for cancels would be great!

Hi @weotch,

This is a known issue and it’s not just Slack, it’s just the way we treat cancelled builds. The cancelled builds are also labelled as failed internally, and thus the notifications. Should this change, we’d let you know.

Thanks a lot for update and quick reply, Looking for same issue, Really appreciate for help.

Adding a few more specific observations re: canceled builds:

  1. Production badge shows Failed. I expect it to show status from the last non-auto-canceled build.
  2. Bot PR comment drops the Browse the preview link if a preview had been created but then a successive build is canceled. Expect the latest good PR preview link to be retained.

do you get any details about the deployment in a triggered function and send a notification from a function after determine if the build was cancelled or really did fail?

Hi @dahlbyk,

Thank you for the observations. We’'ve passed those on to the developers so they can take a look and make relevant changes upon review.

@Kevin_Forster,

Even if you use the event triggered functions, since our backend logs that deploy as failed, I believe it will report it also as failed and there’s no other status at the moment that you can check.

One thing you could however try is that, write your own build script and detect an error code in the previous step - so if you get a non-zero exit code from your build command you run another command which would send a notification - this can be a NodeJS file or something else too.

However, do note that once you run this custom build script, you’d have to make sure to send a non-zero exit code so that the build gets failed. Because, if you send 0 as the exit code for your last command, Netlify will treat the build as a success and publish it.

Not a pleasant way to handle this, but might work.

1 Like