1
votes

Is there any way to list all variables that is or was used in release in VSTS?

For example in release definition I can’t get a list that includes also variables from variable groups.

And in past releases I can only list environment or release variables but not both, including group variables, in one view.

For example in Octopus Deploy this was possible: to list all variables in release.

2

2 Answers

1
votes

You can execute any of below command in PowerShell task as below:

Get-childItem env:
ls env:

Then it will list all the release variables, group variables and environment variables etc.

Note:

  • If you have multiple environments in your release definition, only the environment variables which you execute PowerShell task in the environment will be listed. Other environment variables in other environments won't be listed.
  • If the user defined variable name contains ., it will be convert to _ in the list output. Such as a release variable my.var will be shown as my_var in the output.
1
votes

Slightly easier than adding a PowerShell task, if you look at the deployment logs for a release, the "Initialize Job" output starts with the full list of environment variables for the job.

Sample output:

2019-01-25T14:45:19.9999366Z ##[section]Starting: Initialize job
2019-01-25T14:45:19.9999668Z Current agent version: '2.144.2'
2019-01-25T14:45:20.0025462Z Prepare release directory.
2019-01-25T14:45:20.0038060Z ReleaseId=1, TeamProjectId=xxxxxxxx, ReleaseDefinitionName=xxxxxxxx
2019-01-25T14:45:20.0116729Z Release folder: D:\a\r1\a
2019-01-25T14:45:20.0259515Z Environment variables available are below.  Note that these environment variables can be referred to in the task (in the ReleaseDefinition) by replacing "_" with "." e.g. AGENT_NAME environment variable can be referenced using Agent.Name in the ReleaseDefinition: 
                [AGENT_HOMEDIRECTORY] --> [C:\agents\2.144.2]
                [AGENT_ID] --> [3]
                [AGENT_JOBNAME] --> [Release]
                [AGENT_MACHINENAME] --> [fv-az576]
                [AGENT_NAME] --> [Hosted Agent]
                [AGENT_OS] --> [Windows_NT]
                [AGENT_OSARCHITECTURE] --> [X64]
                [AGENT_RELEASEDIRECTORY] --> [D:\a\r1\a]
                [AGENT_RETAINDEFAULTENCODING] --> [true]
                [AGENT_ROOTDIRECTORY] --> [D:\a]
                [AGENT_SERVEROMDIRECTORY] --> [C:\agents\2.144.2\externals\vstsom]
                [AGENT_TEMPDIRECTORY] --> [D:\a\_temp]
                [AGENT_TOOLSDIRECTORY] --> [C:/hostedtoolcache/windows]
                [AGENT_VERSION] --> [2.144.2]
...