Skip to main content

[Server] How to allow-list branches to override “Only build pull requests” on a project

How do I allow-list additional branches?

For Server 3.x and 4.x admins, you can allow-list branches on your CircleCI Server instance.
By allow-listing specific branches, you are setting them as default branches.
This would therefore allow builds on these branches to run regardless whether these branches are pull-requests or not.
​
A common use-case can be when your project has multiple release branches like main, staging and production.
​
​

Note we recommend you test out on a non-critical project first, if available.

Steps

  1. Run kubectl exec -it <frontend pod> -n <namespace> bash to exec into one of the frontend pod

  2. Within the Bash session in the frontend pod, execute lein repl :connect 6005

  3. Within this Clojure REPL session, you can confirm a project's current features by running

    (circle.http.api.admin-commands/get-project-features-by-url "<URL to project>")
  4. Override the list of default branches for this projects by running

    (circle.http.api.admin-commands/set-project-feature-by-url "<URL to project>" :pr-only-branch-overrides "<list of branch names>")
  5. Rerun step 3 to confirm the :pr-only-branch-overrides feature is now applied.

For step 3, an example of the command would look like:

# example project: https://github.com/acmeorg/realitycheckuser=> (circle.http.api.admin-commands/get-project-features-by-url "https://github.com/acmeorg/realitycheck")

For step 4, here is the example, where we override our default branches:

user=> (circle.http.api.admin-commands/set-project-feature-by-url "https://github.com/acmeorg/realitycheck" :pr-only-branch-overrides "main, release.*")# output below
{:pr-only-branch-overrides "main, release.*"}


​Note that your output can vary based on your project's settings.

In addition, the `set-project-feature-by-url` command is a PUT operation (overwrite) as per step 4;
You have to supply the full list of branches you want overridden each time you run the command.
​
​Java Regular Expressions are supported for the branches.
​
​

Additional Resources

Did this answer your question?