How to use Stage variables in a stage. Which is set to repeat
Let’s say you have a usecase to use stage variables in a stage set to repeat. Then how do we achieve this?
- When you define a variable in Stage “test1”, called test.
The expression <+pipeline.stages.test1.variables.test> resolves properly to harness (the default variable) when you set a repeat set, the same expression return null.
-
You can use <+stage.variables.Variable> instead of the <+pipeline.stages.test1.variables.test> variables in your stages to achieve your usecase.
-
When we create execution nodes for the Looping strategy (Repeating), we give them different identifiers, in my case Post_Deploy_0, Post_Deploy_1, Post_Deploy_2…
-
If the stage is not in a Looping strategy, then approach with a fully qualified path <+pipeline.stages.test1.variables.test> will work perfectly fine. But for repeating designs, the logic changes, so we should use a variable expression instead of a fully qualified expression.
So this is how you can use stage variables in a stage set to repeat.