Create a CIRCLE_TARGET_BRANCH envar


#1

Having an environment variable during a PR build that gives the target/base branch would be extremely useful. Related to: Only build Pull Requests targetting specific branch


#2

We really need this behavior to be implemented. It’s the only way to dispatch diff strategies between source and target branches on pull requests, to be able to just analyze modified files on this PR with static code analyzers.

It’s a pretty common use case.


#3

Is this behaviour still being planned out? I would love to see a feature like this!


#4

I’d really like to see this, too.

Right now, I’m hacking around this by grabbing it from the Github API:

    if [[ -n ${CIRCLE_PR_NUMBER} ]]
    then
    curl -L "https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64" \
      -o jq
    chmod +x jq
    url="https://api.github.com/repos/org/repo/pulls/$CIRCLE_PR_NUMBER?access_token=$GITHUB_TOKEN"
    target_branch=$(
      curl "$url" | ./jq '.base.ref' | tr -d '"'
    )

#5