How can I make a deployment fail with deploy.ps1?
My deployment, which is using AppVeyor agent on a Windows Server 2019, executes deploy.ps1. I am trying to make the deployment fail based on the outcome of this script, but so far have not been successful.
I tried 'Exit 1', I tried 'throw "Foobar"', but the deployment always shows up as green, e.g. success.
How can I make the deployment fail?
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Feodor Fitsner on 25 May, 2023 11:07 PM
Make sure you have
$ErrorActionPreference = "Stop"
in the beginning of yourdeploy.ps1
script.2 Posted by rgelb on 25 May, 2023 11:54 PM
@Feodor This works with both 'Exit 1' and 'throw "Foobar"?
Support Staff 3 Posted by Feodor Fitsner on 25 May, 2023 11:56 PM
It definitely should work with "throw".
Feodor Fitsner closed this discussion on 25 May, 2023 11:56 PM.