Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AzurePipelinesPullRequestInfo fails to detect if build is running in the context of a GitHub Pull Request #4410

Open
2 tasks done
ap0llo opened this issue Dec 20, 2024 · 0 comments

Comments

@ap0llo
Copy link

ap0llo commented Dec 20, 2024

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 int but the Ids on github,com exceeded int.MaxValue some time ago (for example, in one recent PR I opened, the id was 2246475303)
  • The fix would be to use long instead, 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.IsPullRequest should return true
  • AzurePipelinesPullRequestInfo.Id should 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.Id or context.AzurePipelines().Environment.PullRequest.IsPullRequest

Output log

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant