# My workflow keeps running despite having filters

**URL:** <https://discuss.circleci.com/t/my-workflow-keeps-running-despite-having-filters/28836>\
**Category:** Build Environment\
**Created:** [March 7, 2019, 10:50pm UTC](https://discuss.circleci.com/t/my-workflow-keeps-running-despite-having-filters/28836 "2019-03-07T22:50:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![yusuf](https://avatars.discourse-cdn.com/v4/letter/y/c68b51/32.png) [@yusuf](https://discuss.circleci.com/u/yusuf)\
**Post date:** [March 7, 2019, 10:50pm UTC](https://discuss.circleci.com/t/my-workflow-keeps-running-despite-having-filters/28836/1 "2019-03-07T22:50:26Z")

</div>

I am using the MacOS environment to run a workflow for my iOS app. The problem is the filters don’t seem to prevent the workflow from running when I push to a branch that shouldn’t cause it to run. For example, it should only run when pushed to the master branch but when I push to the develop branch it runs. Why??

Here is my code:

```auto
version: 2.1
jobs:
  test:
    macos:
      xcode: "10.1.0"
    working_directory: /Users/distiller/project
    environment:
      FL_OUTPUT_DIR: output
      FASTLANE_LANE: test
    shell: /bin/bash --login -o pipefail
    steps:
      - checkout
      - restore_cache:
          key: 1-gems-{{ checksum "Gemfile.lock" }}
      - run:
          name: Install Gemfile for Fastlane
          command: bundle check || bundle install --path vendor/bundle
      - save_cache:
          key: 1-gems-{{ checksum "Gemfile.lock" }}
          paths:
            - vendor/bundle
      - restore_cache:
          key: 1-pods-{{ checksum "Podfile.lock" }}
      - run:
          name: Install CocoaPods
          command: pod install
      - save_cache:
          key: 1-pods-{{ checksum "Podfile.lock" }}
          paths:
            - ./Pods
      - run:
          name: Run Tests
          command: bundle exec fastlane $FASTLANE_LANE
      - store_artifacts:
          path: output
      - store_test_results:
          path: output/scan

  beta:
    macos:
      xcode: "10.1.0"
    working_directory: /Users/distiller/project
    environment:
      FL_OUTPUT_DIR: output
      FASTLANE_LANE: beta
    shell: /bin/bash --login -o pipefail
    steps:
      - checkout
      - restore_cache:
          key: 1-gems-{{ checksum "Gemfile.lock" }}
      - run:
          name: Install Gemfile for Fastlane
          command: bundle check || bundle install --path vendor/bundle
      - save_cache:
          key: 1-gems-{{ checksum "Gemfile.lock" }}
          paths:
            - vendor/bundle
      - restore_cache:
          key: 1-pods-{{ checksum "Podfile.lock" }}
      - run:
          name: Install CocoaPods
          command: pod install
      - save_cache:
          key: 1-pods-{{ checksum "Podfile.lock" }}
          paths:
            - ./Pods
      - run:
          name: Submit to Testflight
          command: bundle exec fastlane $FASTLANE_LANE
      - store_artifacts:
          path: output/MyApp.ipa

workflows:
  version: 2.1
  build-test-beta:
    jobs:
      - test:
        filters:
          branches:
            only: master
      - beta:
          requires:
            - test
          filters:
            branches:
              only: master

```

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [March 8, 2019, 8:37am UTC](https://discuss.circleci.com/t/my-workflow-keeps-running-despite-having-filters/28836/2 "2019-03-08T08:37:02Z")

</div>

My config that restricts builds to master:

```auto
workflows:
  version: 2
  test-build:
    jobs:
      - build:
          filters:
            branches:
              only: master

```

Check your indentation is correct, and also switch temporarily from version 2.1 to 2, to see if that is the problem.

---

<div class="post-metadata">

**Author:** ![yusuf](https://avatars.discourse-cdn.com/v4/letter/y/c68b51/32.png) [@yusuf](https://discuss.circleci.com/u/yusuf)\
**Post date:** [March 8, 2019, 8:48am UTC](https://discuss.circleci.com/t/my-workflow-keeps-running-despite-having-filters/28836/3 "2019-03-08T08:48:50Z")

</div>

It seems to auto convert it to version 2, and removes the filter on the -test job. Strange

---

<div class="post-metadata">

**Author:** ![yusuf](https://avatars.discourse-cdn.com/v4/letter/y/c68b51/32.png) [@yusuf](https://discuss.circleci.com/u/yusuf)\
**Post date:** [March 8, 2019, 9:50am UTC](https://discuss.circleci.com/t/my-workflow-keeps-running-despite-having-filters/28836/4 "2019-03-08T09:50:27Z")

</div>

Ok so when I changed to version 2.0 it worked. Would be good to get it working with v2.1 so I can use commands, but I’ve just no idea what was wrong. The documentation is useless too

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [March 8, 2019, 3:06pm UTC](https://discuss.circleci.com/t/my-workflow-keeps-running-despite-having-filters/28836/5 "2019-03-08T15:06:44Z")

</div>

Hello. How can the docs be improved? They are open-source and we welcome pull requests and suggestions for improvement.

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [March 8, 2019, 5:17pm UTC](https://discuss.circleci.com/t/my-workflow-keeps-running-despite-having-filters/28836/6 "2019-03-08T17:17:09Z")

</div>

> [@yusuf](#):
>
> The documentation is useless too

That sounds rude, even if you did not mean it to be. Let’s have a collaborative atmosphere here please. (Fellow user, not an employee).

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [March 8, 2019, 5:54pm UTC](https://discuss.circleci.com/t/my-workflow-keeps-running-despite-having-filters/28836/7 "2019-03-08T17:54:54Z")

</div>

The spacing is off on the `test` job filters. Secondly, you do not need to specify `version: 2.1` under workflows — it’s only needed at the top of the config.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [March 18, 2019, 5:55pm UTC](https://discuss.circleci.com/t/my-workflow-keeps-running-despite-having-filters/28836/8 "2019-03-18T17:55:00Z")

</div>

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