'How to set Variables in Release pipeline in Azure DevOps pipeline
I have searched all the documents about how to set variables to pass the variable during the run time build pipeline and only told me how to set in .yaml. But how to use it in release pipeline runtime variables?
Suppose I have a Generate-manifest.ps1 file which I will run to generate manifest.json file which representing the latest release packages with version number inside it. Version: 1.0.0. This version value should passed as a variable during runtime. I need help to do this.
Manifest.json file looks like this.:
{
"version": "1.0.0",
"timeStamp": "2021-05-07T09:41:34+00:00",
"packages": [
{
"name": "data-service",
"type": "docker-image",
"version": "REL-1.0.5367"
},
{
"name": "feedback-service",
"type": "docker-image",
"version": "REL-1.0.6099"
},
]
}
Solution 1:[1]
Based on your explanation I understand that you need to read version variable during the build pipeline and pass this variable on the release pipeline in order to use it on BuildNumber for example.
First you will need to use a powershell task to read the version value from the .json file.
$deployment_config = Get-Content manifest.json -raw | ConvertFrom-Json
$versionNumber = $deployment_config.version
Then you can change the BuildNumber variable on build pipeline
$buildnumber = -join("v",$versionNumber ,"_","$(Build.BuildNumber)")
And also update
Write-Host "##vso[build.updatebuildnumber]$buildnumber"
You can then use the varialbe $(Build.BuildNumber) on release pipeline
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | GeralexGR |


