My workflow keeps running despite having filters

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:

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

My config that restricts builds to master:

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.

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

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

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

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).

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.

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