Tag filter not firing in workflow

We are building and deploying to a test environment for each push to the master branch on GH. When we push to master with a tag matching ver-nnn.nnn, we want to build and deploy to prod. This was working fine in circle ci v 1.0 but we haven’t got it working after the upgrade to 2.0. Can you see anything obviously wrong with our yaml below?

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build
      - deploy-dev:
          requires:
            - build
          filters:
            branches:
              only: master

      - deploy-prod:
          requires:
            - build
          filters:
            tags:
              only: /^ver-[0-9]+\.[0-9]+$/
            branches:
              ignore: /.*/

Seems like branches: ignore: /.*/ could be a problem. The .* regex matches any branch and so everything is ignored? But I’ve seen this in examples… Or is ^ and $ the problem?

It’s worked for me in the past, though I use YAML references. Maybe put your YAML and my YAML into this parser to see if they produce different data structures? You may have an indentation problem.

That yaml parser is a great debugging tool, thanks for sharing! Not solved yet, I guess I have to dig in and experiment. I find the ignore /.*/ filter very confusing. What does it actually mean to ignore every branch?

I think ignoring a branch is useful if you want a tag-only trigger. If you don’t also have the ignore, you match on the default branch filter, which is “all”, even if you also have a tag filter.

You need to apply the tag filters to the build job. Right now you’re not telling it to run for tags, so it’s not. Since deploy-prod requires build, it’s not running either.

1 Like

Thank you, that solved the problem!

1 Like

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