tag:help.appveyor.com,2012-11-13:/discussions/questions/59471-how-to-cancel-deployment-agent-deployment-in-before-deployps1AppVeyor: Discussion 2022-09-06T01:09:33Ztag:help.appveyor.com,2012-11-13:Comment/556313822022-09-05T07:50:53Z2022-09-05T07:50:55ZHow to cancel Deployment Agent deployment in before-deploy.ps1<div><p>I am deploying an application on a Windows machine using the following steps:</p>
<p>Deploying artifact packages as a Windows application<br>
<a href="https://www.appveyor.com/docs/deployment/agent/#deploying-artifact-package-as-a-windows-application">https://www.appveyor.com/docs/deployment/agent/#deploying-artifact-...</a></p>
<p>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?</p>
<p>Example</p>
<ol>
<li>In before-deploy.ps1, disable task in Windows task scheduler and wait for operations already running to finish<br></li>
<li>Deploy a new exe file to run in task scheduler<br></li>
<li>Enable the task scheduler task in deploy.ps1</li>
</ol>
<p>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?</p></div>miyaketag:help.appveyor.com,2012-11-13:Comment/556313822022-09-05T16:32:08Z2022-09-05T16:32:08ZHow to cancel Deployment Agent deployment in before-deploy.ps1<div><p>Just throw an exception in <code>before-deploy.ps1</code>, e.g. <code>throw "Deployment aborted!"</code></p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/556313822022-09-06T01:09:10Z2022-09-06T01:09:10ZHow to cancel Deployment Agent deployment in before-deploy.ps1<div><p>I got it. Thank you very much for your support.</p></div>miyake