In AzureDevOps How to change the value of the variable based on the branch the CI pipeline is running for.
Like for dev branch var-value = "develop" where as for master branch var-value = "master".
You can use a simple PowerShell script that checks the pre-defined variable Build.SourceBranchName and set the variable value:
$branch = "$(Build.SourceBranchName)"
if($branch -eq "master")
{
Write-Host "##vso[task.setvariable variable=var-value]master"
}
else
{
Write-Host "##vso[task.setvariable variable=var-value]develop"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With