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!
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:
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
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.