Azure-devops-docs: System.PullRequest variables not populating

Created on 28 Aug 2018  路  12Comments  路  Source: MicrosoftDocs/azure-devops-docs

Hi,

Referring to the documentation: https://docs.microsoft.com/en-us/vsts/pipelines/build/variables?view=vsts

I'm using a Command Line task in the Build Definition and logging the below variables to check the values. But none of them are populating as a result of a PR.

echo $(System.PullRequest.IsFork)
echo $(System.PullRequest.PullRequestId)
echo $(System.PullRequest.PullRequestNumber)
echo $(System.PullRequest.SourceBranch)
echo $(System.PullRequest.SourceRepositoryURI)
echo $(System.PullRequest.TargetBranch)
Script Logs.txt

Pri3

Most helpful comment

This is closed but I do not see any solution. These variables are also not working for our releases.

All 12 comments

Are you using TFS or Azure DevOps Services? is your repo in GitHub or Azure Repos?

I'm having this issue as well. I'm trying to provide this value in my release name format:
PR $(System.PullRequest.PullRequestId), rev $(rev:r)
Using Azure DevOps online with Git source control.
Per the docs cited by the OP,

System.PullRequest.PullRequestId: The ID of the pull request that caused this build. For example: 17. (This variable is initialized only if the build ran because of a Git PR affected by a branch policy.)

I do have a branch policy on the master branch that requires PR validation. Presumably that's what the above quote is referring to? In any case what arrives in the release name is the string literal PR $(System.PullRequest.PullRequestId), rev 2). Perhaps the variable only populates during build and then must be passed along as a variable over to release?

I am facing this issue as well, trying to use $(System.PullRequest.PullRequestId) in our release job.

Also, hit the same issue...

Also hit the same issue. Any news?

This is closed but I do not see any solution. These variables are also not working for our releases.

I guess this is not supposed to work in the release pipeline. But I would love something like that, too, as I would like to deploy based on the PR Number to a different environment. On the docs I only see this variable mentioned for builds, not for releases...

I'm using GitLab. Cant use $(System.PullRequest.SourceBranch) in either Build or Release

I'm unable to use $(System.PullRequest.SourceBranch) as well for Bitbucket project

I'm having the same issue trying to use pullrequests variables in azure pipelines for github repo

I am unable to use $(System.PullRequest.SourceBranch) as well for Azure Devops project

Classic microsoft closing an issue without any solution or even reply.
Also facing this

Was this page helpful?
0 / 5 - 0 ratings