Check in PowerShell script if deployment is running

I have a custom machine policy that checks if certain items exist, and if they do are they running (websites, windows services, etc.). This then fails the health check if they are not. If a “Check Tentacle Health” task is triggered during a deployment, this may mean that the environment fails its health check.

How can I check within a machine policy script if a deployment is currently running within an environment, and skip the tests if it is?

Hi Richard,

Thanks for getting in touch.

The API ( https://github.com/OctopusDeploy/OctopusDeploy-Api/wiki/Deployments#operations ) offers a way to get deployments.

An example is in Octo.exe using the command list-latestdeployments https://octopus.com/docs/api-and-integration/octo.exe-command-line as part of the details you get back you will see State: Executing and you’ll be able to filter by ‘environment’, and get your health check script to factor that in.

It makes use of the same code that displays the dashboard summary: https://github.com/OctopusDeploy/OctopusClients/blob/master/source/Octo/Commands/ListLatestDeploymentsCommand.cs#L119

Regards,
Nick