Is there any way to pass a variable group name to a release pipeline using REST API without editing the release definition.
I am able to do it using the following
$defurl = "https://vsrm.dev.azure.com/org/proj/_apis/release/definitions/13?api-version=5.1"
$def = Invoke-RestMethod -Uri $defurl -Method Get -Headers $header
$def.variableGroups="VariableGroupName"
$json = @($def) | ConvertTo-Json -Depth 99
$udef = Invoke-RestMethod -Uri $defurl -Method Put -Body $json -ContentType "application/json" -Headers $header
But the problem is "Put" request updating the Original definition. Is there any way to pass the Variablegroup without editing the release definition. Is this a good practice to edit the Release defnition on the fly to pass the variable group.
$definition
looks like? – Theo$def.variableGroups="VariableGroupName"
. Shouldn't you convert$def
to json and use that in your nextInvoke-RestMethod
call rather than$definition
? – Theo