Branches not being ignored

I am attempting to ignore ALL branches and only start the jobs on a tagged build if the tag contains the correct value.

I am using

workflows:
  version: 2
  deploy_staging:
    jobs:
      - ios_deploy_staging:
        filters:
          tags:
            only: /^staging-[0-9]+(\.[0-9]+)*$/
          branches:
            ignore: /.*/
      - android_deploy_staging:
        filters:
          tags:
            only: /^staging-[0-9]+(\.[0-9]+)*$/
          branches:
            ignore: /.*/
      - ios_deploy_prod:
        filters:
          tags:
            only: /^prod-[0-9]+(\.[0-9]+)*$/
          branches:
            ignore: /.*/
      - android_deploy_prod:
          filters:
            tags:
              only: /^prod-[0-9]+(\.[0-9]+)*$/
            branches:
              ignore: /.*/

Weirdly only the

android_deploy_prod

is being ignored, all the remaining jobs run on all branches.

Has anyone seen this before? Frustrating.

Hi @pocockn,

I believe the behaviour you’re seeing is caused by the missing indentation of the filters block, for all jobs except android_deploy_prod; this is preventing the defined filters from being taken into consideration.

You’ll need to add a two-character indentation to each line from filters to ignore, the same way you did for the filter associated with the android_deploy_prod.

Let me know if this helps.

1 Like