I wonder if there is a way to query the deployment history on a deployment target programmatically just like on UI.
What I would like to achieve in my bootstrapping script is to know if the current deployment target is a new one or not by looking at the number of previous deployments on it.
Thanks for getting in touch! Great question, and I’m sure we can come to a good option though which one might depend on a bit more details about what exactly you’re after. I’ll throw a couple resources down below where one might be helpful, otherwise I’d be more than happy to consider this further after learning a bit more about your goals/requirements.
We have an available API script in our sample script repo to retrieve recent deployments to a machine which might help with part of the answer.
Possibly another option would be to add a run condition to your step based off a deployment system variable, perhaps Octopus.Tentacle.PreviousInstallation.PackageVersion checking if it exists or not on the target the step is being run on.
I hope that helps in some way, and let me know what you think!