I can’t seem to get an powershell script step to stop the deployment. At first I thought it was because we were throwing an exception, and not exiting with 1. So I updated the script to write out the message, and exit 1, but this still doesn’t work:
if(!$success)
{
Write-Host “Verification failed - could not get appropriate response within timeout period.”
EXIT 1
}
I updated the process and re-created the release, I see the written message but the exit does not appear to work because it still considers the step as successful, hence the green outline:
It feels like in principal what you’re doing should work. I’ll spin up a test VM to look over this.
In the meantime, can you confirm what version of Octopus Server you are running?
EDIT: I’ve just seen that you posted in the Octopus Cloud section, so I assume you’re on the latest version
Also, Calamari will check the $LastExitCode variable too, so it would be worth trying to insert your code directly into that.
e.g.
$LastExitCode = 1
You can also try the Fail-Step command detailed here.
I’ve updated the step to use Fail-Step, as that seems clear and obvious to me, however it still returns an error code of 0. I’ve double and triple checked I’ve updated all usages of that step, and recreated the release each time.
If I run the step directly outside of the deployment process it fails correctly, as you can see below:
Update for anyone stumbling on this in the future. This was a bug where by tasks running under an Azure target role weren’t failing when told to. It has been fixed and now works correctly.