The preferred way to implement pipelines these days in Azure DevOps is via
YAML. Which makes the pipeline part of your code and is automatically version controlled.
When you were used to the classic way of creating release pipelines, you might have used environment scoped variables. These scoped variables were great to specify to which environments you wanted to provision/install/deploy/… your solutions. Like when you were releasing DEV solutions, it would use the DEV environment credentials.
In the YAML pipelines, the best way would be to make use of variable groups, but these still support only one environment.
A way to support these different environments per branch would be by creating a variable group per branch/environment.
Using dynamic variable groups
The solution to use dynamic variable groups is by using expressions.
Info: More information about these expressions can be found here - Azure DevOps Expressions.
Here you can see an example:
The funny side note, yesterday Sebastien Levert and I were figuring out how we could make this work. One critical thing we forgot was the
- in front of the expression. Once we found the solution, Sebastien said that he was going to blog, as he has not done it, and I needed the same approach today, it is time to share it.