Only build Pull Requests targetting specific branch



I’m pulling this feature request from the following thread.

In order to provide a way to build pull requests which only target a specific branch, the target branch will have to be included in the payload from the vcs. I’m not sure if it is or not, or if we can make this information available via an environment variable. (i.e. $CIRCLE_BRANCH)

Build only pull request to a specific branch

It is possible to set circle to get webhooks for pull requests with the right permissions , which i think u already ask and get.
you get the following json(example from the github api site):

so you get ‘head’ json object which is the branch the PR was opened for and ‘base’ which is where the PR is going to be merged.
you can expose BOTH as env variable using ~/.circlerc
you can register for this webhook just like u do for regular commit pushes, only u ned now to diffrenciate and it’s up to the user to decide what to do.


I would definitely want this, especially for managing builds on OSX which are time delimited for the month. Right now there are very few controls to empower customers to have control over when and how they make OSX builds.


+1 … Post must be at least 10 characters


My workaround if anyone finds it useful, I use a build step like this:

  name: Merge to target branch
  command: |
    if [[ -n ${CIRCLE_PR_NUMBER} ]]
    curl -L "" \
      -o jq
    chmod +x jq
      curl "$url" | ./jq '.base.ref' | tr -d '"'
    git config circleci
    git config
    git pull origin $target_branch