Determine Pull Request branch with environment variable


Buddy provides the BUDDY_EXECUTION_BRANCH to determine to branch being build.
However when the build is triggered by a Pull Request (BUDDY_EXECUTION_PULL_REQUEST_ID is set) the BUDDY_EXECUTION_BRANCH is not set. So there is no way to determine the branch from which the PR originated nor the branch target by the PR.

Several other CI provide this information for example Travis with TRAVIS_BRANCH and TRAVIS_PULL_REQUEST_BRANCH.

Ideally, for builds triggered by a PR, Buddy should set BUDDY_EXECUTION_BRANCH to the branch targeted by the PR (e.g. master) and BUDDY_EXECUTION_PULL_REQUEST_BRANCH to the branch from which the PR originated (e.g. feature/my-new-feature).


Hey Pierre,
Sorry to keep you waiting for the answer.

You’re right – this is some valuable info that’s worth adding to Buddy. We’ve added your request to the backlog. As for Travis, it most probably takes the information from the GitHub’s webhook. It might take a while to introduce though, as Travis is only focused on GitHub and we also have Bitbucket and GitLab onboard.

In a couple of weeks we’re going to discuss all ENV requests. We’ll keep you informed.


Thanks for the answer.
I’m maintaining which attempt to provide a uniformed way to read CI environment variables. So that’s great to know you are going to look at all the environment variable request.