Search code examples
octopus-deploy

Can Octopus Deploy have variables in variables


This is a system Octopus Deploy Variable:

#{Octopus.Action[Deploy To Server].Output.Package.InstallationDirectoryPath}

The text "Deploy to Server" is the name of the step in my project that deploys the Nuget Package to the server. This variable gives the install location of the NugetPackage.

I am wondering if I can make this more generic:

#{Octopus.Action[#{DeploymentStep}].Output.Package.InstallationDirectoryPath}

#{DeploymentStep} is itself a variable with the value of "Deploy to Server"?

I tried this and it not did do the substitution when it tried to run. But I am hoping there is a different syntax for variable in variable substitution.

(I want to do this so I can make this the default value for a Step Template.)


Solution

  • It can be done; but you need to use slightly different syntax!

    Variable substitution syntax: http://docs.octopusdeploy.com/display/OD/Variable+Substitution+Syntax

    $deploymentStep = "#{DeploymentStep}"
    
    $installationDirectory = $OctopusParameters["Octopus.Action[$deploymentStep].Output.Package.InstallationDirectoryPath"]