BUILDKITE_PULL_REQUEST is not correctly detected
I have dynamic pipeline to run some checks only if it's PR. And the checks are mandatory before merging the PR on github.
Agent Version | 2.3.2
And sometimes the BUILDKITE_PULL_REQUEST value is false evening merging changes into the feature branch.
This sounds like a pull requests cache issue. @sj26 / @toolmantim?
Oh dear, sorry that doesn't sound good :-(
I agree this doesn't sounds like an agent issue. @exiadb, could you email us the specifics of this case to [email protected] including links to the builds with which you're having trouble? Meanwhile I'll close this issue here.
We're experiencing this bug as well. It seems to fail about half of the time.
It’s probable that we are receiving the branch / commit notification from GitHub before we get the pr:open notification, which means the build is already created. Subsequent commits to the branch should always show up with a correct BUILDKITE_PULL_ENV. Does that sound right?
Drop us an email with an example build to [email protected] and we will investigate!
On 17 Nov 2017, at 8:20 am, Brad Wilson [email protected] wrote:
We're experiencing this bug as well. It seems to fail about half of the time.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Yes, after reviewing, that's exactly what we've been seeing. It's always the first commit. Do you have any suggestions for how to mitigate?
P.S. Thank you for the quick response!
It's a very tricky problem to solve, as quite often the two events are separated by quite some time as developers generally push a branch first and then create a pull request from that branch.
We have been discussing ways to mitigate this from a UX perspective, for instance updating the page dynamically when the PR comes in, but trying to get it into the environment vars is a hard problem to solve in the sense that the variables are out of our control.
About the only practical way to ensure you only get builds for pull requests is to only trigger builds on pull requests or on master. This is what we do for some of our repositories and it works really well provided your team has a pull-request centric workflow. This is what our config looks like:

That actually works perfectly for us. Thank you!