DeployFailed.ps1 support
Today's Octopus Deploy release includes support for a DeployFailed.ps1
script, a feature I mentioned in a recent blog post about how Octopus handles rollbacks.
Background
During a deployment, Tentacle normally runs the following steps:
- Extracts the package from NuGet
- Runs
PreDeploy.ps1
- Runs XML config transforms
- Replaces XML config
appSettings
andconnectionStrings
- Runs
Deploy.ps1
- Configures IIS websites
- Runs
PostDeploy.ps1
(See our pages on XML configuration, PowerShell script support, and IIS websites for details on these steps)
DeployFailed.ps1
If steps 2-7 fail, Tentacle will now look for a DeployFailed.ps1
script, and invoke that. It will have access to the same variables that the other PowerShell scripts get. This is a good place to put recovery actions.
Note that if step 1 fails, the DeployFailed.ps1
won't be called. There are a few reasons for this:
DeployFailed.ps1
might not have been extracted anyway- Files it depends on may not have been extracted
- Tentacle checks for free disk space prior to installing a package, so this should be pretty rare in the first place
- Extracting the package is an isolated task, so there's nothing to recover from in the first place
One feature that would be nice is to pass the path to the last installed package, which your recovery script could use when rolling back. Tentacle doesn't have enough information to do that yet, but it will when Auto-purge Tentacles is implemented, since both require keeping a list of previously installed applications.