How do I use a single variable for multiple hosts

I have inherited an Octopus deploy env, so I apologize if this is a simple question. We have a step that runs a powershell script that use #{hostip} as a variable. When I look in Octopus the variable has two values. 10.1.0.1 and 10.1.0.2. What seems to be happening is that when Octo deploy runs its evaluates that #{hostip} variable and grabs the last one it reads, so we are getting a duplicate IP. 10.1.0.2 is being assigned by the script.

I was told this worked before, but I cant see how. Any thoughts?

Hi @washburnjoe ,

Thanks for getting in touch! Are these split into separate values, or are they comma-separated values in the same variable? In the latter, I set up a quick test and successfully written both values with the following (confirming the syntax in this doc page).

$multiVal = "#{each host in hostip} - #{host}#{/each}"
Write-host $multiVal

Which printed out - 10.1.0.1 - 10.1.0.2.

Does that help? Let me know how you go!

Best regards,

Kenny

Thank you so much

Hi,

You’re very welcome, please let us know if you have any questions or concerns in the future!

Best regards,

Kenny

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