Can not filter jobs by tags in workflows?

circle.yml

#1

There is my workflows:

workflows:
  version: 2
  build-test-deploy:
    jobs:
      - versions
      - install
      - test:
          requires:
            - install
      - build:
          requires:
            - install
      - deploy-pre:
          requires:
            - build
            - test
          filters:
            tags:
              only: /v.*/
      - deploy-normal:
          requires:
            - deploy-pre
          filters:
            tags:
              only: /v(\d)+(\.(\d)+)+/
      - deploy-test:
          requires:
            - deploy-pre
          filters:
            tags:
              only: /(v(\d)+(\.(\d)+)+)-(alpha|beta)/

The last 3 jobs are always excute

i try to add this code in filters

branchs: 
       ignore: /.*/

But when I add a tag in Github, it won’t execute too

Anyone meet the same problem?
How can I filter the job by tags?


#2

Spelling error - this should be branches.

If that does not fix it, see this demo file.


#3
  1. You’ll want to do the spelling fix that @halfer mentions.
  2. Of the last 3 jobs, deploy-pre depends on build and test while all three depend on install, build and test indirectly. You aren’t telling CircleCI to run install, build and test on tags. Since they won’t run, none of their dependencies will.

For the example you provided and what I think is your desired behavior, here is what your workflow config should look like:

workflows:
  version: 2
  build-test-deploy:
    jobs:
      - versions
      - install:
          filters:
            tags:
              only: /v.*/
      - test:
          requires:
            - install
          filters:
            tags:
              only: /v.*/
      - build:
          requires:
            - install
          filters:
            tags:
              only: /v.*/
      - deploy-pre:
          requires:
            - build
            - test
          filters:
            branches:
              ignore: /.*/
            tags:
              only: /v.*/
      - deploy-normal:
          requires:
            - deploy-pre
          filters:
            branches:
              ignore: /.*/
            tags:
              only: /v(\d)+(\.(\d)+)+/
      - deploy-test:
          requires:
            - deploy-pre
          filters:
            branches:
              ignore: /.*/
            tags:
              only: /(v(\d)+(\.(\d)+)+)-(alpha|beta)/

#4

it is not the reason


#5

it is really hard to reply in https://discuss.circleci.com:expressionless:

i have tried same thing

but it is still not work.


#6

You didn’t try what I suggested as I don’t see the tag filters for build, test, and install in the GitHub config you just linked.


#7

but i just want to filter the last 3 jobs deploy-pre, deploy-normal and deploy-test

and build , test , and install would be executed anytime


#8

CircleCI will not run a job with a Git tag is pushed unless you tell it too in the config. It doesn’t do it by default.

Branches are on by default, tags are off by default.


#9

Then what should I do?
Do I need 2 workflows?

I have no idea.


#10

You can use the Workflow I gave you in my post above.


#11

:smile:

it is working…
when i push a tag to origin, the tag will target new jobs.
but i can not see any new workflows in dashboard, so that i think it is not work.

it is better if i can see the workflows in dashboard. Just like the gitlab-ci


#12

I am not sure what you mean by this, could you elaborate?


#13

image

I mean that i can see anything changed in [https://circleci.com/gh/xyy94813/workflows], after i pushed a new tag to github