Passing an Array as a variable to PreDeploy Script


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?


The best bet is to set the values to:


Then in PowerShell:

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


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”


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.