Closed jason-johnson closed 4 years ago
Same can be said for System.PullRequest.PullRequestNumber
In order to consolidate to fewer feedback channels, we've moved suggestions and issue reporting to Developer Community. Sorry for the delay/confusion.
@jason-johnson I was finally able to get my use case working by setting some variables to a string, then coalesce to either choose the macro value or keep the string null so it'll collapse correctly:
variables:
${{ if eq( variables['build.reason'], 'PullRequest' ) }}:
date: ''
${{ if ne( variables['build.reason'], 'PullRequest' ) }}:
date: ${{ '$(Date:yyyyMMdd)' }}
name: ${{ coalesce( variables['date'], '$(System.PullRequest.PullRequestNumber)', 'Yet another fallback value' ) }}$(Rev:.r)
Hope this helps
For PR builds
variables['system.pullRequest.sourceBranch']
should be set but is actually null at template compile time. I have some additional jobs that should run only when the pull request is coming from a branch following a convention defined within my team so I tried to do the following:The problem is that the second part will never be included no matter what the build is. I checked the logs from the run and in
initializeLog
is see the following:So here we see that
variables['System.PullRequest.SourceBranch']
wasNull
when this evaluation happened but in the Azure Devops build screen I see it set at "queue time".There are at least 3 other issues that are a result of this problem but I decided to open this as a new issue because those all describe a symptom while this appears to be the root problem each has in common. The duplicates are #274, #435 and #276.