In Azure DevOps sharing variable between stages was a complex task earlier. Recently Microsoft has released one feature which has sorted this problem. Now we can Pass variable between stages. This new feature which has been released recently (Spring 2020) is very helpful and will allow pipeline stages to communicate better and efficiently. Output variables may now be used across stages in a YAML-based pipeline. You can share information, variables etc across stages in a pipeline.
Below mentioned snippet is an example in which I am sharing variable value between stages and validating it for stage run.
I have tested the scenario and it works !
But there is one point which require our attention is that stage dependency ! Make sure if you are passing variable between two stages, then one has to be dependent on another :)
That’s all for this post. Happy learning.
Ref: Find more details on it.