Is there a way to detect when Octopus is pushing a project up to an environment for the first time? I’d like a step to occur only on the first push up to say our QA environment, but I’m unsure how to detect that via a variable of some kind to ensure that the step only occurs then.
Can you advise on the best way (and if it’s possible) to do this?
Thanks for reaching out to us with this question. If I may ask, what are you looking to do on first deployment?
If you only care about the whole Environment scope then the Octopus.Release.CurrentForEnvironment.Number built in variable could work as it will be empty on first deployment. Something like this script below would setup an output variable that you can bind to in subsequent steps.
However, this is value is for the environment and not the individual machines in this environment. So if you add a machine into this environment later, it will show the same result as the existing machines. So for something like machine provisioning this will not work.
If you wanted to do something similar at the machine level you could check for some indicators like a file or a registry key and follow the same approach. You could also setup a separate project for environment provisioning instead.
Another option that comes to mind here is if you are up for some manual handling, then the Script Console under Tasks can allow you to run ad-hoc scripts against machines on an as needed basis.