How can I send a notification when a deployment fails in Octopus Deploy?

When a deployment fails (or if a specific step fails), I would like to send out a notification via email, slack, pagerduty, or by some other means. How can I do that with Octopus?

There are a couple of options in Octopus Deploy to accomplish this. It depends entirely on your requirements.

Option 1: Project Notifications

By making use of run conditions you can configure a notification step to run if:

  • Deployment fails
  • A very specific step fails
  • Always

In this screenshot I have a slack notification configured to always run, even if the deployment fails.

You could also call a script which performs some sort of business logic. Based on the result of that logic, you would set an output variable. The subsequent step would use that output variable to determine if it should run.

For example, in this deployment process, it is generating a delta script and in staging and production an approval will occur.

The process will run a script to determine if the delta script can be automatically approved and sets an output variable.

The manual intervention and notification step use that output variable to determine if it should run.

I use a variable to store the output variable result so I don’t have to remember the syntax.

Option #2: Subscriptions

You can configure subscriptions to send out an email or webhook notification when a deployment fails.

Subscriptions are more of a blunt instrument than a scalpel. You can’t have the nuance of “only notify me if this specific step fails.” However, you can setup a small service to accept subscription notifications and then use the API to gather more information to make a decision on who to notify.