How to set a variable to be used by many steps

Hello,

I have a process with several steps. I use some Output Variables to set some values for some steps outcome. I need something like a global variable from which I can read a value inside any step.

For example:
Step1 runs with success
Step2 runs with success
Step3 needs to know about the result of Step1, but Step3 has a template and inside the template I would like to use something general, not an Output variable retrieved directly from Step1 (which I could do but I don’t want to).

How can I do that?

Thanks

Hi Razvan,

Thanks for getting in touch.

Output variables were designed for this purpose. You mention that you could do this, but don’t want to. Can you explain why (to help us better understand)?

Cheers
Mark

Hi Mark,

Yes, I can explain.
Step3 has a template which is used by multiple steps. And inside the template I don’t want to access a specific Output variable from a previous specific step, but something more general, aplicable to the whole process, like a global variable or smth. I would like that Step1 and Step2 to set the value of that global variable, and Step3 accesses that value.
I understand that this is not possible with Output variable, where you are bound to that only step where the output variable is defined.

Do you need more details?

Thank you,
Razvan

Hi Razvan,

This is possible with output variables. You are not bound only to the step where the output variable is defined.

For example, you could have a script step called “StepA” with a PowerShell script that sets an Octopus variable like so:

Set-OctopusVariable -name "MyGlobalOctopusVariable1" -value "see me"

Then in another step called “StepB” you can access that output variable like so:

#{Octopus.Action[StepA].Output.MyGlobalOctopusVariable1}

Please see the example in the Output variables documentation for more details.

Hope this helps.

Cheers
Mark