Exercise - create and manage variable groups
In this exercise, you'll investigate Variable Groups.
Steps
Let's now look at how a release pipeline can use predefined variables, called Variable Groups.
Like how we used task groups, variable groups provide a convenient way to avoid redefining many variables when defining stages within pipelines and even when working across multiple pipelines.
Let's create a variable group and see how it can be used.
On the main menu for the Parts Unlimited project, click Pipelines, then click Library. There are currently no variable groups in the project.
Click + Variable group to start creating a variable group. Set Variable group name to Website Test Product Details.
In the Variables section, click +Add, enter Name, enter ProductCode, and in Value, enter REDPOLOXL.
You can see an extra column that shows a lock. It allows you to have variable values that are locked and not displayed in the configuration screens.
While it's often used for values like passwords, notice an option to link secrets from an Azure key vault as variables.
It would be a preferable option for variables that provide credentials that need to be secured outside the project.
In this example, we're just providing details of a product used in testing the website.
Add another variable called Quantity with a value of 12.
Add another variable called SalesUnit with a value of Each.
Click Save to save the new variable group.
On the main menu, click Pipelines, click Releases and click Edit to return to editing the release pipeline we have been working on. From the top menu, click Variables.
In the left-hand pane, click Variable Groups.
Variable groups are linked to pipelines rather than being directly added to them.
Click Link variable group, then in the Link variable group pane, click the Website Test Product Details variable group (notice that it shows you how many variables are contained). In the Variable group scope, select the Development, Test Team A, and Test Team B stages.
We need the test product for development and testing, but we don't need it in production. If required in all stages, we would have chosen Release for the Variable group scope instead.
Click the Link to complete the link.
The variables contained in the variable group are now available for use within all stages except production, just the same way as any other variable.