I have my source code repository in github and my pipeline in Azure devops. I am trying to execute certain tasks in my pipeline based on the source branch of a pull request. The pipeline gets triggered on PR. However, when I try to get the below attributes of a Pull request from my yml pipeline, I get the message shown in the screenshot below. It basically states command not found for all the values. Is there anything obvious that could cause this. Or is this not how these values are expected to be fetched? Any help is much appreciated.
trigger:
branches:
include:
- feature/azure-pipeline
- develop
- release/*
exclude:
- features/*
- master
pr:
branches:
include:
- develop
- main
stages:
- stage: TestStage
jobs:
- job: unit_test
displayName: 'Unit test Job'
pool:
vmImage: 'macos-latest'
variables:
- name: currentBranch
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
value: $(System.PullRequest.TargetBranch)
${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
value: $(Build.SourceBranch)
steps:
- task: DownloadSecureFile@1
displayName: 'Download CSSM secrets'
name: secureKeys
inputs:
secureFile: 'cssmkeys.properties'
- script: |
echo Target Branch is $(System.PullRequest.TargetBranch)
echo Source Repository URI is $(System.PullRequest.SourceRepositoryURI)
echo PullRequest Id is $(System.PullRequest.PullRequestId)
echo Source Branch is $(System.PullRequest.SourceBranch)
echo Current Branch is $(value)
EDIT Link to the system variables page - https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml