Octopus variable inside of project variables

Hello

I would like to dynamically input the installation directory of my Deploy step into the web/app.config.

  • In my process, I have 4 steps of type “Deploy Nuget Package”.
  • In each I am using a Custom install directory. The “install to” parameter is set to a project variable, e.g.#{InstallDir.Web}, #{InstallDir.Batch}, etc. Essentially, the install directory is different for each machine role.
  • I have a web.config and app.config variable called LOGO_PATH, which must be an absolute path to the install directory, plus a filename at the end. e.g. <add key="LOGO_PATH" value="D:\wwwroot\MyApp\\logo2.gif" />
  • In my project variables I have this:

Name: LOGO_PATH

Value: #{Octopus.Action[Octopus.Step.Name].Package.CustomInstallationDirectory}\logo2.gif

  • When I deploy, other variables are replaced fine, even variables that reference other project variables. But this one, it gets put as a literal, e.g. <add key="LOGO_PATH" value="#{Octopus.Action[Octopus.Step.Name].Package.CustomInstallationDirectory}\logo2.gif" />

Any idea what I’m doing wrong?

Thanks
Tom

Hi Tom,
It looks like you are trying to use the step variable before they are available. These step variables are actually only produced at the end of the step for use by subsequent actions.

What you probably want to use instead is OctopusOriginalPackageDirectoryPath i.e.
<add key="LOGO_PATH" value="#{OctopusOriginalPackageDirectoryPath}\logo2.gif" />

Give that a go and let me know how if you run into any further difficulty. Thanks for getting in touch.
Cheers,
Rob

Rob,

Thanks for the feedback.

I tried that path and it’s putting in the following:
<add key="LOGO_PATH" value="D:\inetpub\wwwroot\DV-2\BE.GCS.Web\1.0.1_5\logo2.gif" />

What I am expecting is
<add key="LOGO_PATH" value="D:\wwwroot\GCS\logo2.gif" />

D:\wwwroot\GCS is my custom path. It looks like #{OctopusOriginalPackageDirectoryPath} isn’t looking at my custom path.

I could, of course, just use my custom path variable in there – but I have a different custom path for each package. I am deploying 4 Nuget packages and they all have the same appSettings.

How can I get the custom install path in there without having to create a separate variable entry scoped out for each server role?

Thx
Tom

I got this working. The variable #{Octopus.Action.Package.CustomInstallationDirectory} got me what I needed. I didn’t realize you could use the “Action” part without specifying the name.

Thanks