Unable to use filters for tags

I am migrating some pipelines to v2, and ALL the tag filters are not working. I’ve tried both single and multiple workflows without success.

Here’s an example of an workflow where I expect ALL tasks to run when there are NO tags:

workflows:
  version: 2
  build-and-test:
    jobs:
    - prepare:
        filters:
          tags:
            ignore: /.*/
    - test:
        requires:
          - prepare
        filters:
          tags:
            ignore: /.*/
    - compile:
        requires:
          - test
        filters:
          tags:
            ignore: /.*/

Here’s another example where I expect my workflow to run ALL tasks ONLY when there are tags:

workflows:
  version: 2
  build-and-test:
    jobs:
    - prepare:
        filters:
          tags:
            ignore: /.*/
    - test:
        requires:
          - prepare
        filters:
          tags:
            ignore: /.*/
    - compile:
        requires:
          - test
        filters:
          tags:
            ignore: /.*/
  build-and-deploy:
    jobs:
      - prepare:
          filters:
            tags:
              only: /.*/
      - test:
          requires:
            - prepare
          filters:
            tags:
              only: /.*/
      - compile:
          requires:
            - test
          filters:
            tags:
              only: /.*/
      - setup_deployment:
          requires:
            - compile
          filters:
            tags:
              only: /.*/
      - deploy:
          requires:
            - setup_deployment
          filters:
            tags:
              only: /(.*)v(.*)/

Finally, another example when I expect some tasks to run when there are tags and some when there aren’t:

workflows:
  version: 2
  build-and-test:
    jobs:
    - prepare:
        filters:
          tags:
            ignore: /.*/
    - test:
        requires:
          - prepare
        filters:
          tags:
            ignore: /.*/
    - compile:
        requires:
          - test
        filters:
          tags:
            ignore: /.*/
  build-and-deploy:
    jobs:
      - prepare:
          filters:
            tags:
              only: /.*/
      - test:
          requires:
            - prepare
          filters:
            tags:
              only: /.*/
      - compile:
          requires:
            - test
          filters:
            tags:
              only: /.*/
      - setup_deployment:
          requires:
            - compile
          filters:
            tags:
              only: /.*/
      - deploy:
          requires:
            - setup_deployment
          filters:
            tags:
              only: /(.*)v(.*)/

None of the examples provided are working. Where can I raise a bug about this issue?

Playing more with this workflow, I found out that the behavior is repeatable when there are no tags. When tags are declared (and the variable CIRCLE_TAG) the filter works. How can I make a different workflow when there are no tags if filters do not work if there are no tags?

For future users landing here:

At the moment of this reply, there’s no support from CircleCI to this scenario, where some tasks may have filters and others may not. Either ALL tasks have filters or not.

This is the workaround I used - a bash test to define if I have a tag or not:

- run:
name: Check for existing git tags
command: |
[[  $CIRCLE_TAG && ${CIRCLE_TAG-x} ]] && echo "Tag Found: $CIRCLE_TAG" || echo "No tag was found - no deployment will happen"

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