~
System variable System.PullRequest.TargetBranch
cannot be used in templates. What is the workaround for below.
~
System variable System.PullRequest.TargetBranch
cannot be used in templates. What is the workaround for below.
It kind of depends where you want to use Environment
variable. If in deployment job to set environment, you can't as it has to be known at compilation time.
If you want to use in place which can be established at runtime, you can use logging command to setup variable.
- pwsh: |
if ( 'refs/heads/release-uat' -in @('$(Build.SourceBranch)','$(System.PullRequest.TargetBranch)') )
{
Write-Host "##vso[task.setvariable variable=Environment;]uat"
}
However, variable set in that way can't be use in some places.