Generated config from dynamic config + git tag

workflows:
  version: 2
  javabuild:
    jobs:
      - commit-check:
          filters:
            tags:
              only: /.*/
      - unit-tests:
          requires:
            - commit-check
          filters:
            tags:
              only: /.*/
      - check-pmd:
          requires:
            - commit-check
          filters:
            tags:
              only: /.*/
      - checkstyle:
          requires:
            - commit-check
          filters:
            tags:
              only: /.*/
      - build-service:
          requires:
            - commit-check
          filters:
            tags:
              only: /.*/
      - docker-build:
          filters:
            tags:
              only: /.*/
          requires:
            - build-service
            - unit-tests
            - checkstyle
            - check-pmd
        
      - deploy-dev:
          requires:
            - docker-build
          filters:
            tags:
              only: /^dev.*/
            branches:
              ignore: /.*/

I am using dynamic config and wanted to use git tag to trigger deploy in dev. The above is the generated config yml after initial setup. I have tried to explicitly state filters but when I pushed git tag the deploy-dev jobs still wasn’t triggered. Is there something wrong with my script?

You need each workflow with a filter to include

            branches:
              ignore: /.*/

It should also be possible to change the logic you have as all the workflows that have a dependency based on another workflow should not need a filter section, apart from the last workflow where you are being selective, and you may be able to use a condition rather than a filter at this point.

1 Like

Hi, thank you for the response. But if I refer from this documentation Using Workflows to Schedule Jobs - CircleCI. I don’t think I need to add ignore branches on the filter.

OK, this is where a Circleci staff member may need to join in or a question raised with the support team (who do reply to even free account holders).

The section of examples you are following is mainly written using workflows/version=2 which means they have not been updated for some time since 2.1 become a thing back in Oct 18. Setting the version to 2 or 2.0 is documented as a way to generate warnings for historic changes rather than changing the behaviour of the running script, which is based on 2.1.

The problem you are facing is a common issue raised and seems to come from the way that circleci processes filters, you may write

          filters:
            tags:
              only: /.*/

But by default it seems to be processed as

          filters:
            branches: 
              only: /.*/
            tags:
              only: /.*/

With the script doing a match only against branch unless it returns a ‘true’ value based on an ignore check, at which point it will try the tag check - so the default branch filter always wins. Depending on the repo used this can be seen in the “Preparing environment variables” report as you will likely see CIRCLE_BRANCH defined but not CIRCLE_TAG.

As far as I can tell, just about every user of circleci gets caught by this issue as they move from branch based to tag-based builds.

1 Like