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

How do I whitelist additional branches?

For Server 3.x and 4.x admins, you can whitelist branches on your CircleCI Server instance.
By whitelisting 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.

Please note that this is a delicate process, and we would recommend you to test out on a testing/staging CircleCI Server instance, 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/realitycheck

user=> (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.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.