Empty OctopusParameters in deploy.ps1

We have a NuGet package being deployed which uses a deploy.ps1 file to kick off some scripts. Inside the deploy.ps1 file we can see some OctopusParameters populated, like Octopus.Machine.Hostname and Octopus.Tentacle.CurrentDeployment.PackageFilePath, but any of the parameters for the action are empty, like Octopus.Action[Deploy DSC package].Output.Package.InstallationDirectoryPath. We’re accessing them in the following way:

$hostname = $OctopusParameters[“Octopus.Machine.Hostname”]; # populated properly
$installationPath = $OctopusParameters[“Octopus.Action[Deploy DSC package].Output.Package.InstallationDirectoryPath”]; # not populated

Is it something to do with the spaces in our step name? I’ve tried wrapping the step name in speech marks too, but with no luck:

$OctopusParameters[“Octopus.Action[‘Deploy DSC package’].Output.Package.InstallationDirectoryPath”]
$OctopusParameters[‘Octopus.Action[“Deploy DSC package”].Output.Package.InstallationDirectoryPath’]
$OctopusParameters[“Octopus.Action["Deploy DSC package”].Output.Package.InstallationDirectoryPath"]

Hi,

Thanks for reaching out. Using the variable in the following format from deploy.ps1 should be enough.

$OctopusParameters['Octopus.Action[Deploy DSC package].Output.Package.InstallationDirectoryPath']

See attached screenshot for reference also

If this doesn’t work, could you please send us your deploy.ps1 file so we can check it?

Thanks,

Dalmiro

Attached is our deploy.ps1 and a screenshot of the package in NuGet Package Explorer. I’ve tried with single and double quotes, encoded quotes around the step name, all with no luck.

deploy.ps1 (614 Bytes)

Hi,

Try using $OctopusParameters['Octopus.Action.Package.CustomInstallationDirectory'] instead .

Let me know how it goes

Dalmiro

Thanks. That worked. Why did it not need a step name?

Hi Rob,

Variables that include the step name like $OctopusParameters['Octopus.Action[Deploy DSC package].Output.Package.InstallationDirectoryPath'] are called Output variables, and they are only available after the step that creates them has finised.

The variable $OctopusParameters['Octopus.Action.Package.CustomInstallationDirectory'] is a var that is scoped to a specific step only, and for that reason its not necessary for you to specify a step name.

Glad to hear it worked :slight_smile:

Dalmiro