How can I make a deployment fail with deploy.ps1?

rgelb's Avatar

rgelb

25 May, 2023 10:00 PM

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?

  1. Support Staff 1 Posted by Feodor Fitsner on 25 May, 2023 11:07 PM

    Feodor Fitsner's Avatar

    Make sure you have $ErrorActionPreference = "Stop" in the beginning of your deploy.ps1 script.

  2. 2 Posted by rgelb on 25 May, 2023 11:54 PM

    rgelb's Avatar

    @Feodor This works with both 'Exit 1' and 'throw "Foobar"?

  3. Support Staff 3 Posted by Feodor Fitsner on 25 May, 2023 11:56 PM

    Feodor Fitsner's Avatar

    It definitely should work with "throw".

  4. Feodor Fitsner closed this discussion on 25 May, 2023 11:56 PM.

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