Azure deployment and postdeploy scripts

Hi

I need to run a script (powershell or regular DOS) after deployment which basically copies one file to another location.
(the file being copied will be different for each environment we deploy to).

I cannot find a way to determine where my application will be deployed. I’ve looked at executing PostDeploy.ps1, using the “built in post deploy” powershell script editor within an Octopus Deploy Process as well as adding in another step in the process simply to run a powershell script.

Either my scripts are not running (the separate postdeploy.ps1 I don’t believe is running) or the scripts cannot find the environment variables ($OctopusParameters) I’m expecting.

In reality my apps will be installed on E:\approot\app… but when I try (say from the builtin postdeploy editor in OD) specify a line such as:

write-host $OctopusParameters[‘Octopus.Action[web azure].Output.Package.InstallationDirectoryPath’]

I’ve tried many variables, only very very few come back with any content.

Can someone explain where I’m going wrong?

Thanks

Ken

the result is nothing.

Hi Ken,

You can try using $OctopusParameters[OctopusOriginalPackageDirectoryPath] or $OctopusParameters[Octopus.Action.Package.CustomInstallationDirectory], this should work in either PostDeploy.ps1 in NuGet package or in the built-in PostDeploy script editor.

If that fails, you can print out all the variables available in $OctopusParameters with the little snippet below, this will show you what information you have available when running PowerShell from the built-in PostDeploy script editor.

Write-Output "In CustomPostDeployment script"
foreach($variable in $OctopusParameters)
{
    Write-Output $variable
}

Hope that helps!

Thank you and warm regards,

Henrik