Using output variables scoped to a target machine

I am trying to implement using a variable from one step in another when the variable needs to be scoped to the target machine. It is described in the documentation but I don’t understand how to implement.

The documentation I am looking at is here: http://docs.octopusdeploy.com/display/OD/Output+variables

My process is as follows:

I am trying to get a value from a power-shell script run in STEP A and then using it in STEP B. The deployment will run on multiple machines so Steps A and B will run on MACHINE 1 and MACHINE 2, etc.

STEP A:
Set-OctopusVariable -name “TestResult” -value “Passed”

STEP B:
$TestResult = $OctopusParameters[“Octopus.Action[StepA].Output.TestResult”]

I was able to get the value into STEP B, but I don’t understand the instructions on how to scope it to the target machine. Will the scope be determined automatically? Do I need to add anything to the Variables section in octopus?

Thanks.

Hi,

Thanks for reaching out. The scope per machinewill be automatically determined like you said. For example:

  • You run Step A in machines M1 and M2. This means that in the background, 2 copies of “TestResult” will be created.

  • When you run Step B on M1 to try to get the value of $OctopusParameters["Octopus.Action[Step A].Output.TestResult"], the value that will be used is the copy of TestResult that was created in Step A on M1. Same logic will apply for M2.

In short: Use $OctopusParameters["Octopus.Action[Step A].Output.TestResult"] and Octopus will be smart enough to get you the copy of it that belongs to that machine.

Hope that helps!
Dalmiro