How to cancel Deployment Agent deployment in before-deploy.ps1

miyake's Avatar

miyake

05 Sep, 2022 07:50 AM

I am deploying an application on a Windows machine using the following steps:

Deploying artifact packages as a Windows application
https://www.appveyor.com/docs/deployment/agent/#deploying-artifact-package-as-a-windows-application

I include and run the before-deploy.ps1 and deploy.ps1 scripts in that step. In this before-deploy.ps1, I would like to cancel the deployment when certain conditions are met.Is this possible?

Example

1. In before-deploy.ps1, disable task in Windows task scheduler and wait for operations already running to finish
2. Deploy a new exe file to run in task scheduler
3. Enable the task scheduler task in deploy.ps1

I want to wait for a certain period of time until the operation in 1 ends, and if it does not finish, I want to cancel the processing of 2 and 3. What should I do?

  1. Support Staff 1 Posted by Feodor Fitsner on 05 Sep, 2022 04:32 PM

    Feodor Fitsner's Avatar

    Just throw an exception in before-deploy.ps1, e.g. throw "Deployment aborted!"

  2. 2 Posted by miyake on 06 Sep, 2022 01:09 AM

    miyake's Avatar

    I got it. Thank you very much for your support.

  3. miyake closed this discussion on 06 Sep, 2022 01:09 AM.

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

Recent Discussions

27 Jan, 2023 08:06 PM
27 Jan, 2023 08:05 PM
25 Jan, 2023 03:23 PM
25 Jan, 2023 03:22 PM
23 Jan, 2023 03:29 PM