Passing an Array as a variable to PreDeploy Script

Hi,

I’m trying to pass an array of string values to PreDeploy by putting the following into a variable through the OD interface

"string1", "string2", "string3"

i have also tried

@("string1", "string2", "string3")

In PreDeploy I try to access these as

$values = $OctopusParameters["Deployment.Values"]

The values are assigned, but it is no longer an array (i.e. $values.Count is not 3). Is there any way I can fix this?

Hi,

The best bet is to set the values to:

string1,string2,string3

Then in PowerShell:

$values = $OctopusParameters["Deployment.Value"].Split(",")

Paul

How to set Octopus.Tentacle.CurrentDeployment.TargetedRoles dynamically in predeploy.ps1?

It seems that is an array and won’t work with
Set-OctopusVariable -Name “Octopus.Tentacle.CurrentDeployment.TargetedRoles” -Value = “a,b,c”

Hi,

Thanks for getting in touch! Even though the TargetedRoles is an array, this is not the issue.
TargetedRoles is not a variable that can be changed, it’s a system defined variable only available to Octopus.

Vanessa