I have a few variables created in Variable Groups with the following names:
CodeNetworkShare.Dev
CodeNetworkShare.Test
CodeNetworkShare.Prod
I imported this variable group in my Release Definition. Then I tried the following ways to use this in Release definition
I created a local variable in the Release Definition as follows:
Name = CodeNetworkShare1
Value = $(CodeNetworkShare.$(Release.EnvironmentName))
I tried to use it directly in the task using the following expression:
$(CodeNetworkShare.$(Release.EnvironmentName))
Neither of the above approaches worked. Is there any other way I can get this to work? Does VSTS Release Definitions nested variables? If it's not supported at the moment are there plans to support this in the future?
VSTS has a different approach: you can defined the variables at the Release Definition level or at the Environment level (see https://www.visualstudio.com/en-us/docs/build/concepts/definitions/release/variables).
The two approaches you listed can work good. And VSTS release support nested variables.
Except define a variable in release definition (or environment variable) or use it directly, you can add the variable CodeNetworkShare1
=$(CodeNetworkShare.$(Release.EnvironmentName))
directly in variable group. Then in your release definition, it can use applied with different values for different environment names.
VSTS now has the option of linking variable groups to different environments within the same release definition. Create separate variable groups for each environment (dev, test, prod, or maybe just dev and prod, if e.g. test is in production environment) and then link that group to correct environments in the link page. See more in my other answer here: Is there a way to use VSTS Variable Groups per environment?