How to get the list of variable of release pipelines in Azure devops
using Azure CLI
There's no command available in Azure Devops CLI to list the variables of release pipeline, you have to use az devops invoke + rest api to get the variables you want in long response.
To get release variables we can use this rest api, let me convert it into az devops invoke
command :
az devops invoke --org https://dev.azure.com/MyOrgName/ --area release --resource definitions --http-method Get --route-parameters project=MyProjectName definitionId=ReleaseDefinitionID --api-version 5.1 -o json
More details:
1.You should replace the MyOrgName, MyProjectName and ReleaseDefinitionID with the values on your side. And the ReleaseDefinitionID
is something easy to find when we edit a release pipeline in web portal:
2.Since variables in release pipeline can be scoped in one stage or whole pipeline. Assuming I have VarA:Test1
in stage1, VarB:Test2
in stage2, and VarC:Test3
in whole release pipeline. The response would look like this structure:
"variables": {
"VarC": {
"value": "Test3"
}
},
"variableGroups": [],
"environments": [
{
"id": 1,
"name": "Stage 1",
...
"variables": {"VarA" xxx},
"id": 2,
"name": "Stage 2",
...
"variables": {"VarB" xxx}...
The variables have their different levels, please be careful with them. Hope it helps.
Update1:
To use az devops
command, someone who doesn't have this extension needs to add the devops extension using something like az extension add --name azure-devops
.