Excluding a branch from CI

How we can exclude a branch from building?

Have a look at https://circleci.com/gh/behdad/harfbuzz

gh-pages is the branch we like to exclude from build: https://github.com/behdad/harfbuzz/tree/gh-pages

Last minute thought, should we put a dummy empty .circleci/config.yml? If so, what it is should be in it?

Done on https://github.com/behdad/harfbuzz/pull/599 feel free to suggest a better solution. Thanks

1 Like

Your branch filter is in the wrong place. When you’re using workflows the branch filter needs to go into your workflows declaration. You can find the relevant section of the docs here.

Note Workflows will ignore job-level branching. If you use job-level branching and later add workflows, you must remove the branching at the job level and instead declare it in the workflows section of your config.yml, as follows:

You can try something like:

workflows:
  version: 2

  build:
    jobs:
      - job1:
          branches:
            ignore:
              - gh-pages
      - job2:
          branches:
            ignore:
              - gh-pages

You’ll need to include it in each job until the workflow level filtering feature is implemented.

We have lots of jobs and adding three lines for each is a bit annoying but given the config is not even included on gh-pages branch, will that be effective? Thanks.

1 Like

Yes, I see it’s a bit annoying, and we’ll improve that in the future. If using a different config for that branch doesn’t cause any issues for you I say roll with that. I can’t think of any issues at the moment that it could cause other than being confusing for other people. Maybe someone else will chime in and share some insights on the pitfalls of multiple configs per branch.