In Travis TRAVIS_BRANCH
yields the upstream branch, e.g. master
for a PR.
However CIRCLE_BRANCH
yields pull/6003
- how do we I get the upstream branch on CircleCI?
1 Like
Is anyone actually reading this? I think getting the target branch for a PR is a major use case …
CC @CircleCI-Employees
Right now I’m using sth. like this, subject to rate limiting by github.
if [ -n ${CIRCLE_PR_NUMBER:-} ]; then
local base_branch=$(curl -fsSL https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER | jq -r '.base.ref')
else
local base_branch=$CIRCLE_BRANCH
fi
Since this information is contained in the webhook CircleCI receives from GH (.base.ref
in PullRequestEvent), it would be helpful to just expose this information.
1 Like
This is a great idea! I’ve opened a feature request here: Expose the title and upstream branch of a Pull Request build as an env
Please the post to show your support as that is how the CircleCi product team prioritizes requests.
5 Likes