Build on Pull Requests and all commits

Overview

In some cases you may need to build when a pull request is opened and when a commit is pushed to every branch.

Building on Pull Requests 

In order to build when a pull request is opened, you will need to enable the Only build pull requests feature. Enabling this feature will build when a PR is opened and to commits to your default branch. 

Adding default branches 

You can view your projects default branch branch by using the get a Project API endpoint: https://circleci.com/docs/api/v2/index.html#tag/Project

You may add additional default branches by leveraging the CircleCI API as mentioned in the following support article: https://support.circleci.com/hc/en-us/articles/15222074173723-How-to-allowlist-additional-branches-for-Only-Build-Pull-Requests

To add all branches as default branches, please add ".*" as a default branch. For example: 

 

curl -X PUT \
--header "Circle-Token: <token>" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '{"feature_flags":{"pr-only-branch-overrides": "main, .*"}}' \
'https://circleci.com/api/v1.1/project/<vcs-type>/<org>/<project>/settings'

 

Additional Resources: 

Was this article helpful?
1 out of 2 found this helpful

Comments

0 comments

Article is closed for comments.