Ok - I’m trying to build an confirmation email step, and I need a system variable that will show the “last release deployed to a specific environment/Project combination.” I know there is Octopus.Release.Previous.Number, but it appears that is showing the previous release for “the project”, and not taking into account that the previous project release might not have been deployed to the current environment.
I need this variable to create a delta report that dev teams can look at and see what changes will be pushed to the environment. any help is much appreciated!
Thanks for getting in touch! It appears we do not have a specific variable for that. We do however have the following Octopus.Tentacle.PreviousInstallation.PackageVersion and if you happen to use the release version to match the package version then this will work for you. You would have to define it in a PowerShell step and then call it from the email step.
Thanks Vanessa for the response. I’ve changed our setup so that the package version number will match the release version. However - Could you explain a bit more about “defining it in a powershell step, and then call it from the email step”?
So as part of your package deployment inside the deploy.ps1 you add the following line: Set-OctopusVariable -name "Package1PreviousVersion" -value $OctopusParameters['Octopus.Tentacle.PreviousInstallation.PackageVersion']
Then inside your email step you can call it as such: #{Octopus.Action[STEPNAME].Output[MACHINENAME].Package1PreviousVersion}
You will need to change the step name to the package step name, and the machine name to the nominated machine name.
That worked thanks! however, my requirements have changed a bit, due to requests from our team
No matter what environment I’m deploying to, i need to access the current production release version. I can do this using your solution, if i’m deploying to production, but when i’m deploying to staging, or UAT, i can’t figure out a way to get the current production release. One possible solution is to write the current version to disk somehwere via powershell, then grab that, but it’s not that elegant of a solution. Instead, is there any way I could write to some of global project variable in octopus deploy(like the ones on the variable tab) and then read from it at a later point in time? (ex. create a project variable on the variables tab called “productionVersion” and then update it once we roll out to production…then i could access at a later point?
There is a variable called $OctopusParameters[‘Octopus.Release.Previous.Number’] which contains the latest release created. The problem is that it is not environment-aware and it just returns the previous release, even though that one wasnt deploy to the environment you are currently deploying.
I’ve created a github issue to have this variable be environment-aware