Find previous deployment path

modelling

(Fabian) #1

Hello

During a new release I’d like to copy app_offline.htm file to the currently active deployment folder. This will take my app offline while the new version is deployed.

However i don’t seem to be able to find the previous deployment path.
i tried using Octopus.Release.CurrentForEnvironment.Number but that doesn’t match the folder name.

Is there a way to find the previous deployment path for a web application?

Thank you.

Fabian


(Kenneth Bates) #3

Hi Fabian,

Thanks for getting in touch! I believe you’re after either of these system variables:

Octopus.Tentacle.PreviousInstallation.OriginalInstalledPath which is the directory the previous package version was extracted to. Or if you’re using the custom installation directory feature, you could use Octopus.Tentacle.PreviousInstallation.CustomInstallationDirectory.

Do either of these give you the result you’re after? Let me know how you go or if you have any further questions moving forward. :slight_smile:

Best regards,

Kenny


(Fabian) #4

Hi Kenny

That didn’t work because this is not the folder I am looking for.

Copy-Item : Could not find a part of the path 'C:\Octopus\Work\20180912161703-2

September 12th 2018 09:17:05

Error

4534-119#{Octopus.Tentacle.PreviousInstallation.OriginalInstalledPath}\app_off

September 12th 2018 09:17:05

Error

line.htm’.

I am looking for the path where the IIS web site is pointing to. i.e. the folder where the files are deployed to not where the nuget is extracted to.

So I am looking for this folder D:\Octopus\Applications\DEV\ADBrowser\1.1.20180911.01_2 which is the folder the IIS web site is pointing to.

How can I get this folder inside of my deployment step?

Thank you.

Fabian

8-6325


(Kenneth Bates) #5

Hi Fabian,

Thanks for following up, and I’m sorry to hear that didn’t work for you. It looks like the variable strangely isn’t evaluating for some reason. May I ask for a copy for the script you’ve written to copy the item to the new directory, and your verbose deployment logs from a failed deployment? The following doc page outlines how you can produce and export this log, and I’ll be happy to look more in depth at this to help determine what’s causing this incorrect behavior.

I look forward to hearing back and getting to the bottom of this one!

Best regards,

Kenny


(Fabian) #6

Here is my powershell script

$targetInstallationFolder = $OctopusParameters[“InstallationFolder”].replace("+","_")

$sourceOfflineHtml = Join-Path $OctopusParameters[“AppOfflineFolder”] $OctopusParameters[“AppOfflineFileName”]

$targetOfflineHtml = Join-Path $targetInstallationFolder $OctopusParameters[“AppOfflineFileName”]

#Copy offline file to folder that is currently pointing to the active web application

if (Test-Path($sourceOfflineHtml))

{

    Copy-Item $sourceOfflineHtml $targetOfflineHtml

}

Logs are attached.

Thank you.

Fabian

8-6325

ADBrowserServerTasks-24593.log.txt (91.3 KB)


(Kenneth Bates) #7

Hi Fabian,

Thanks for following up and confirming those details. I’ve been able to reproduce this error when running this script as a script step before deploying the package, however I’m not hitting this when I embed the script as a deployment script in the package step. Does doing this fix the issue for you?

If it doesn’t fix it, could you confirm some additional details to ensure I’m understanding and testing this properly? Your $sourceOfflineHtml variable is composed of essentially #{AppOfflineFolder}\#{AppOfflineFileName} when resolves to D:\Octopus\OfflinePages\app_offline.htm. This is the source folder where your app_offline.htm file resides, and you’re wanting to copy it to the previous installation folder. Is that correct?

I look forward to hearing back!

Best regards,

Kenny


(Fabian) #8

Hi Kenny

Did you have a chance to look at the logs?

I forgot to mention that the InstallationFolder parameter is set to #{Octopus.Tentacle.PreviousInstallation.OriginalInstalledPath}

The AppOfflineFolder is set to D:\Octopus\OfflinePages

The AppOfflineFileName is set to app_offline.htm