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

 

06 Jun, 2024 02:12 PM
06 Jun, 2024 03:49 AM
04 Jun, 2024 03:53 AM
30 May, 2024 04:03 PM
27 May, 2024 02:06 AM
20 May, 2024 09:52 PM