Branches filtering does not work properly with ignore attribute

Hello, I have this workflow structure:

workflows:
  basic-workflow:
    jobs:
      - build-and-test:
        filters:
          branches:
            ignore: some-branch
      - build-test-and-push:
          filters:
            branches:
              only: some-branch

I want to run build-test-and-push when working on a some-branch branch and run build-and-test on every other branch. What this actually results in is that both jobs are scheduled and run when being on a some-branch branch. Is there something wrong with my workflow config? I’m using version 2.1.

Thanks for any help,
Tom

Hi @sykac, welcome to Discuss!

The situation you described is possible and the workflow you provided is close to the setup needed to accomplish it – I think you just had some spacing issues. I believe the filters line under your build-and-test needs to be indented for this to work.

When I tested with the following it worked as you described:

version: 2.1
jobs:
  build-and-test:
    docker:
      - image: cimg/base:stable
    steps:
      - run: echo "hello"
  build-test-and-push:
    docker:
      - image: cimg/base:stable
    steps:
      - run: echo "hello"
workflows:
  basic-workflow:
    jobs:
      - build-and-test:
          filters:
            branches:
              ignore: some-branch
      - build-test-and-push:
          filters:
            branches:
              only: some-branch

Can you give the above a try and see if you continue to encounter issues?

Oh, this was a stupid mistake but didn’t get any errors/warnings anywhere thus I didn’t see it for hours. Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.