Deploy package only if target has older package

Hi,

I have an application consisting of several packages, which have to be installed on different or the same server, depending on the environment. For that part, everything runs fine.

Before a package is to be installed using the “Deploy a Package” step, I want to determine if the installation is necessary, or if it is already installed on this particular server. Is there a way to find out if a package is already installed on the server and if, which version is running? The goal is that I don’t want to all the steps before the deployment of the package (shutdown the application, IIS Web, NLB-Node …) if it is not necessary. I’ve experimented with the variable “Octopus.Tentacle.PreviousInstallation.PackageVersion” but this is always empty.

Kind regards
Hans

Hi Hans,

Thanks for reaching out! The variable Octopus.Tentacle.PreviousInstallation.PackageVersion will only be available within the context of the same step that deployed that same package ID the last time. So if step Deploy Web App deployed the package MyWebApp.1.0.0.nupkg, and now it is deploying 2.0.0, the value of the variable Octopus.Tentacle.PreviousInstallation.PackageVersion within the context of that step will be 1.0.0.

What you are trying to do, which is to skip multiple steps if a specific package has already been deployed, is quite tricky I’m afraid.

The way I would do it is by adding a Powershell step that figures out if the package I’m looking for has been installed(*), then based on that create a boolean variable called ShouldDeployWebApp, and finally set the “Run condition” of all the steps I want to run/skip to run if that variable is set to True

(*) The way I would recommend you to check if a package was successfully installed or not, would be by parsing the contents of the DeploymentJournal.xml file, which is a local file on each Tentacle that we use to see what was deployed when and if it succeeded or not.

Hope that helps,
Dalmiro

Hi Dalmiro,

thank you very much, this could be the solution.
I’ll try this!

Kind regards
Hans

Von: Dalmiro Grañas [mailto:tender2+d18af8ff57@tenderapp.com]
Gesendet: Mittwoch, 22. Februar 2017 17:32
An: Peleska Johann Johann.Peleska@wienerzeitung.at
Betreff: Re: Deploy package only if target has older package [Questions #10886]