Is there a way to stop the entire deployment from a custom step (PS or C#) without triggering the subsequent failure handling steps?
Example: I have a step that checks available disk space and if it is insufficient I want to stop the deployment. Throwing exception from C# is not an option because that would trigger ‘Restore from backup’ and other failure handlers.
Thanks for getting in touch. Sorry to be the bearer of bad news, there is no common way to cancel a Deployment from within the Deployment itself. I do have a couple of suggestions for you:
- We already run a check before starting any deployment step that there is at least 500MB of free disk space.
- You could have the pre-condition step call the Octopus API to cancel the deployment task - which is exactly what the Cancel button does. Be aware there are security implications to this: the task would need access to call the API of your Octopus Server, and an API key to authenticate itself as a User.
- You could create an Output Variable called something like
DeploymentCancelled, then fail the Step, and have your failure handlers test the value of
DeploymentCancelled, and exit early if cancelled.
Hope that helps.
I have to check for configurable amount of space because deployments make a temporary database backup locally and our app servers have very limited amount of space.
I think option 3) will work great for my case. Actually I was not aware Octopus supported output variables.
Thanks for the great product!
Sounds good. Let me know how you get on.