Workflow Job with Tag Filter being run for every commit


#1

I have three workflows defined and associated with my Circle repo.

One of the three looks like this:

...  
deploy-production:
    jobs:
      - docker_production_build:
          filters:
            branches:
              only: master
            tags:
              only: /^v[0-9]+(\.[0-9]+)*$/
...

It is a workflow with one job and no dependencies. My expectation is for this workflow to run only when I push to the master branch with a version tag (see tag pattern). However, this seems to run every time that I push to master. Can help me understand why?


My deploy job always runs, ignoring my tag filter
#2

#3

Thanks, Jon.

I must add that even on removing the branch filter, that job is run for every commit to master and not only for the version tag push which is my expectation. Am I missing something?


#4

Phew, finally got it to work. The solution leverages on the fact that multiple filters are ORed by CircleCI:

...
deploy-production:
  jobs:
    - docker_production_build:
        filters:
          # ignore any commit on any branch by default
          branches:
            ignore: /.*/
          # only act on version tags
          tags:
            only: /^v[0-9]+(\.[0-9]+)*$/
...

I guess it is mostly my fault as it is mentioned in the documentation that branches are included and tags are excluded by default. However, my intuition for mixing the two filters did not match what CircleCI expected.


#5

Hello, can you share what git commands did you run to trigger builds on tags ?
I have tried tens of different combinations without being able to trigger a single build from a git tag …


#6

Hey @tsauvajon,

This should work AFAIK:

# vX.X.X... is the tag pattern that we expect in the 
# CircleCI config to trigger a build
➤ git tag v0.1.0 && git push --tags origin

#7

Indeed the jobs ran, I just didn’t look at the right place (the workflows were just not located at the same place as the branches workflows).

They do not directly appear on the left panel behind the project name, as branch workflows do.
To access them I clicked the project name to go to the project’s workflows at https://circleci.com/:provider/:org/workflows/:project.


#8

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