Execute an Step even if the release is canceled

Hi Team,
We have an requirement to mandatorily execute an step in the process even if it release is canceled. Could you please let me know how I can implement this on Octopus Project ?

Sujesh Sasidharan

Hi @sujeshsasi,

Thanks for getting in touch!

You can set a step to run when a previous step fails or to run regardless of whether the previous step fails or succeeds via the Run Conditions.

However, manually cancelling a deployment will immediately cease all steps from running, even ones that are set to Always Run.


Thanks paul. this is something we have implemented but for us now the scenario is to invoke some mandatory steps like starting of services even when an user cancels the release. How this can be handled in Octopus ?

As mentioned, the cancel function ceases all operations within that deployment, so there isn’t a built-in way to have steps run when a deployment is cancelled.

You could create a script that queries the REST API to check for deployment tasks belonging to that project with the state Cancelled and then run the desired steps when one is found. Your script would likely need to keep track of the date/time of the last cancelled task it found to prevent it from constantly triggering on the same one every time.
The runbook could be set to run on a scheduled trigger but there would inevitably be some lag between the task being cancelled and the runbook executing.

Another option would be to leverage the Subscriptions feature and a webhook to receive an immediate notification whenever a task is cancelled and then process that webhook notification externally to trigger a deployment of the desired steps.

Thanks paul. Could you please provide me any example of how webhooks can be setup using Powershell Script or C#. We cannot use Slack/Azure App functions in our servers.

The webhook would need to be a service or application that is always running and listening for new messages, so Powershell may not be the best option.

You could write something in C# similar to the Azure function example provided in our docs and host it somewhere with a URL that is accessible by your Octopus server.

That is a little outside of what we can advise on though.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.