Create a variable in a process step for use in downstream steps


(Rob Pleau) #1

We have run into a few cases here where we need to create a variable at run time in one step, to use in later steps.

We are aware that you can use Output Variables but this is far from ideal since you have to reference the step that created the variable.

Is there any way possible to create a variable that can be used in multiple steps without having to reference the step it was created in? This is possibly in other platforms like VSTS / ( or now Azure DevOps - Pipelines).

Example, a script step defines a new variable Set-OctopusVariable called MyGlobalOctopusVariable with a value of “test”. I’d expect that I could reference it in a later process step by using PowerShell (in this example) syntax of $MyGlobalOctopusVariable or Octopus Syntax of #{MyGlobalOctopusVariable}.

Closest discussion topic I found for this was here but I don’t think the support staff understood the question, hopefully I explained it better if not please let me know!


(Jayden Platell) #2

Hi Rob,

Thank you for your question. Unfortunately, there isn’t a way to retrieve an output variable without knowing the step name. This isn’t ideal, and we have other users that would similarly like the ability to do this, as evidenced by this suggestion on our uservoice:

If you are wanting to use the output variable in a step template, script package or similar library-style step, and you want to avoid hard-coding the step name, there is a technique you can use. Rather than hard-coding the step name in the variable expression, you can instead use another variable which defines the step name. For example, with a variable named StepName:


It isn’t pretty, but it may be more palatable than hard coding the step name itself.

I hope that helps, and please let me know if I can assist you further.


(Rob Pleau) #3

Hi Jayden,

Thank you for the reply! I added some votes to the user voice. I don’t want to make my process steps too complicated so I’ll eagerly await and hope that the feature gets added in a future release :grinning:


(Jayden Platell) #4

Hi Rob,

Thank you for the votes! Sorry I couldn’t be more useful in this instance. Don’t hesitate to contact us in the future if we can assist with anything else.


(system) #5

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