Issue
I'm setting up a variable in a variable group like:
$json = '{"id":763,"type":"Vsts","name":"rfc","variables":{"rfcvalue":{"isSecret":false,"value":"$(rfc)"}}}'
$pipeline = Invoke-RestMethod -Uri $url -Method Put -Body $json -ContentType "application/json" -Headers @{Authorization= "Bearer $env:SYSTEM_ACCESSTOKEN"}
Write-Host "New Variable Value:" $pipeline.variables.rfcvalue.value
I'm able to get the output as:
New Variable Value: 1200022048
Now, I want to get and use this rfcvalue variable in new stage of the release in Azure ex: QA or Production , I'am getting a blank value in different stages:
Shell script:
echo $(rfcvalue)
echo $pipeline.variables.rfcvalue.value
Output:
2022-10-18T12:53:04.8562998Z
2022-10-18T12:53:04.8567292Z .variables.rfcvalue.value
Idea is to update variable in variable group dynamically and use that value in subsequent stages. Can someone please help me in this.
Solution
I was able to use the variables in different stages of the release pipeline (classic one) by storing those variables in a file and then used below tasks to make it work.
- In first stage, I used "Publish release artifacts". It basically zipped my variable file in release logs.
- In next stages, I just downloaded those files using "Download release artifacts" . Make sure to enable OAuth and Unzip option in the stages.
It helped in downloading the variable file , which I used to store them in another variable which can be utilized in the next stage.
Thank you
Answered By - gaurav sharma Answer Checked By - Clifford M. (WPSolving Volunteer)