-
-
Notifications
You must be signed in to change notification settings - Fork 768
AzurePipelinesPullRequestInfo fails to detect if build is running in the context of a GitHub Pull Request #4410
Copy link
Copy link
Closed
Description
Prerequisites
- I have written a descriptive issue title
- I have searched issues to ensure it has not already been reported
Cake runner
Cake Frosting
Cake version
5.0.0
Operating system
Windows
Operating system architecture
x64
CI Server
Azure DevOps
What are you seeing?
When running a build for a GitHub Pull Request on Azure Pipelines, AzurePipelinesPullRequestInfo.Id returns 0 and AzurePipelinesPullRequestInfo.IsPullRequest returns false even though the corresponding environment variables are set by Azure Pipelines
Analysis
I think I already found the root cause for the issue:
- The Pull Request Id is stored as
intbut the Ids on github,com exceededint.MaxValuesome time ago (for example, in one recent PR I opened, the id was2246475303) - The fix would be to use
longinstead, but I guess this would be a breaking change
Workaround
As a workaround for detecting if a build is a PR build, check if AzurePipelinesPullRequestInfo.Number is greater than 0.
This will return the Pull Request number as shown in the GitHub UI, which should fir well within a int
What is expected?
AzurePipelinesPullRequestInfo.IsPullRequestshould return trueAzurePipelinesPullRequestInfo.Idshould return the id of the pull request (this is different from the PR number)
Steps to Reproduce
Example of a Cake.Frosting-based build that runs into this can be seen here
- Set up a Cake.Frosting-based build in a GitHub-hosted repository
- Set up a pipeline on Azure Pipelines
- In the build, access
context.AzurePipelines().Environment.PullRequest.Idorcontext.AzurePipelines().Environment.PullRequest.IsPullRequest
Output log
No response
Reactions are currently unavailable