Set-OctopusVariable can't handle object arrays?

usability
(Andrew Ralon) #1

Is Set-OctopusVariable not able to handle object arrays?

I’ve been able to pass DateTime PowerShell objects between steps, so I’m surprised object arrays won’t work.

I have two PowerShell steps. The first sets an octopus variable for an object array. The second attempts to read the array.

STEP1:
$myArray.Add($myObject1)
$myArray.Add($myObject2)
Set-OctopusVariable -name “myArray” -value $myArray

STEP2:
$myArray = $OctopusParameters[“Octopus.Action[STEP1].Output.myArray”]
Write-Host “myArray: $myArray”

This outputs:
"myArray: "

Is there a way around this?

#3

Hi @andrewralon

Thanks for getting in touch!

The bit of knowledge that I think you are missing here is that all Octopus variables are strings, which is why passing an array in isn’t working as you might expect. For this to work you would have to read out of the array and pass in a concatenated string of the array objects (which you could then reverse back to an array if required).

Any questions please let me know,

Regards,
Alex

(Andrew Ralon) #4

So Octopus variables are all strings? That makes sense now.

I am now joining the strings together with a separator, and then splitting it into an array in a later step.

Thanks!

#5

No problems, happy to help :slight_smile:

Regards,
Alex

(system) closed #6

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.