I’d like to enable “Only build pull requests” on a project as all feature branches are PR’ed to master and sent to a dev environment. Our production release is simply a push from master to a specific blessed production release branch (prod-release).
So the entirety of what I’d like circle to pick up on is:
any PR in the github repo
any push to prod-release
I’ve tried enabling “Only build pull requests” in the settings and adding prod-release to the branch whitelist. PRs built just fine, but pushes to prod-release were ignored.
If the “Only build pull requests” feature was more like “Only build pull requests unless a branch is whitelisted” I’d be a happy camper
This is also something I would like to see. Using a variant of git-flow, we have two permanent branches that are auto-deployed (to testing and production environments depending on the branch), but we don’t want every push to every branch built, just those that have an associated pull request into one of the permanent branches.
For anyone who wants to have this functionality, but doesn’t want to wait to see if or how CircleCi will implement it, I have a solution. It’s extraordinarily hacky, but it gets the job done.
You can trigger CircleCI builds via their API, and this seems to override your “only build pull requests” setting. So, in order to automate this process, I signed up for CodeShip, added my project, and added only the following as a “Setup” command, with no “Test” commands:
if [ "${CI_BRANCH}" = "{{YOUR BRANCH NAME}}" ]; then curl --request POST https://circleci.com/api/v1.1/project/github/{{YOUR GITHUB USERNAME}}/{{YOUR GITHUB REPOSITORY}}/tree/{{YOUR BRANCH NAME}}?circle-token="${CIRCLE_TOKEN}"; fi
Obviously, be sure to replace all variables like {{YOUR VARIABLE}} with the appropriate values for your setup.
All of this results in CircleCI building all branches with open pull requests, your default branch, and then CodeShip triggering CircleCI builds for whatever branch you’ve named with the above script, which is exactly what I was looking for. Be careful that you’re limited to 100 builds per month on the free version, and there isn’t a way to exclude branches from CodeShip, so you’ll trigger a build with every commit you push. I’m looking to see if there’s a better solution, but this will at least get you started.
CircleCI, please add this functionality natively if at all possible. The ability to build branches not part of pull requests is already present (you still build our default branch regardless of this setting), so please extend that to give us the ability to whitelist other branches.
I’d also like a way to do this, though I’d prefer it was a separate setting than the branch whitelist (because I don’t want to ‘blacklist’ all of our feature branches). Basically hoping for the ability to specify multiple ‘build everything’ branches, sort of like multiple ‘default’ branches, precisely for this “release branch” use-case: We really like the “build only PRs” setting for feature branches but want to build everything both on our master branch and on a release branch.
This would be very useful, my team is working in parallel on multiple “major releases” of our product and we have multiple “main branches” we’d like to always build, while discarding commits in feature branches that aren’t in an open PR yet.