How to limit pipeline or workflow only on 1 branch? Or, how to prevent pipeline from be called on branch without config.yml?

I have a repo with test as default branch, and I want to make circleci start build only on that branch. That means, when I push to any other branch, no pipeline should be runned. (At most times, the other branches won’t have .circleci/config.yml.)

I added those to my .circleci/config.yml as described in https://support.circleci.com/hc/en-us/articles/115015953868-Filter-workflows-by-branch-

workflows:
  build-workflow:
    jobs:
      - build:
          filters:
            branches:
              only: test

But when I push to an other branch without those config, a build is still triggered and errored.

:grimacing: Still waiting for answer. I thought it is a easy question…

Hi @mercury233 ,

Thank you for sharing your question with us!

This error will appear if a config.yml file is not present for any branches regardless if a filter is set or not.

A way to resolve this error would be to pull in the config.yml file from your default branch, or create a dummy config like the following in every branch you wish to not build on CircleCI:

workflows:
  build-workflow:
    jobs:
      - build:
          filters:
            branches:
              ignore: /.*/

The result of this change would be that you would no longer see any “failed” workflows, but would start to see “no workflows” like what happens when a tagged build is not executed.

Please let me know if you have any additional questions or concerns regarding this.

Best Regards

I had this in my default branch:

But the problem still exists:
https://app.circleci.com/pipelines/github/mercury233/ygopro/57/workflows/f2fddca0-4652-4f30-88cc-278aecafa690/jobs/32

:innocent: Still waiting for answer.