Workflows with jobs triggered by Tag

git
circle.yml
workflow

#1

I’m currently switching from CircleCI 1.0 to 2.0 and I’d like to recreate the following behavior:

  • Test-Job is executed for all commits
  • If a commit is tagged with a stage version number scheme: build stage version
  • If a commit is tagged with a prod version number scheme: build prod version

That means I’d like to use to filter by tags. However I can only get either of the following two behaviors:

  1. Test and stage and prod versions are all built on every commit (Tag filter is completely ignored)
  2. Only test is executed. (Tag pushes don’t get recognized and don’t trigger anything)

So these are my workflow definitions for those two cases: (I’ll leave out the prod job for simplicity’s sake)
Tag filters get ignored with:

workflows:
  version: 2
  test-and-deploy:
    jobs:
      - test:
          filters:
            tags:
              only: /.*/
      - deploy_stage:
          requires:
            - test
          filters:
            tags:
              only: /v[0-9]+(\.[0-9]+)*[/]Stage[/]build_.*/

And the config with which CircleCI builds everything on every commit, no matter the Tag:
Tag filters get ignored with:

workflows:
  version: 2
  test-and-deploy:
    jobs:
      - test:
          filters:
            tags:
              only: /.*/
      - deploy_stage:
          requires:
            - test
          filters:
            tags:
              only: /v[0-9]+(\.[0-9]+)*[/]Stage[/]build_.*/
            branches:
              ignore: /.*/

Can anyone tell me what I’m doing wrong?

(edit: yes, I’m sure I pushed the correct tag, so that’s not it.)


#2

You would need to add tag filters on all the jobs in a Workflow as part of a Git tag push. Eg. https://circleci.com/docs/2.0/workflows/#git-tag-job-execution.

Can you please try adding ^ to the regex eg. only: /^v[0-9]+(\.[0-9]+)*[/]Stage[/]build_.*/ and see if that helps?


#3

Hmm that doesn’t do the trick for me. Also I’m sure the regex is correct as our tagging process is automatic and we used that regex with our old 1.0 config.

I also just tried a simpler workflow to debug this:

  debug-tags:
    jobs:
      - tag_test:
          filters:
            tags:
              only: /^debug-.*/
            branches:
              ignore: /.*/
      - hold:
          type: approval
          requires:
            - tag_test
      - tag_test2:
          requires:
            - hold

To just see how things work if the tag match is only at the first job in the workflow. I added those changes, committed, tagged that commit with debug-1 (so it matches that debug regex), but that workflow did not get started when I pushed the changes.

Any suggestions?


#4

I am starting to think that something is wrong here. I just went to the docs, copied out the example workflow that represents how I want my workflow to be and simply replaced the job names:

  circleci-docs-workflow:
    jobs:
      - tag_test:
          filters:
            tags:
              only: /.*/
      - tag_test2:
          requires:
            - tag_test
          filters:
            tags:
              only: /^config-test.*/
            branches:
              ignore: /.*/

It’s the second example in https://circleci.com/docs/2.0/workflows/#git-tag-job-execution
Pasted this in, committed my changes, tagged the commit with config-test1 and pushed. CircleCI only executed the tag_test job.

Also, when I just take that commit and add another tag, say config-test2 and push that tag, CircleCI does not react. It’s like tags don’t make it into CircleCI on my repo with CircleCI 2.0. Can that be? (We’re using BitBucket)


#5

I found out what happened.

Tag triggered workflows are not displayed within the “Workflows” section. When pushing a tag that triggers a workflow, you need to go to that specific instance of the workflow via the Builds section.

That means the builds got started, but they simply are not displayed on the workflows page. Only branch push triggered workflows get displayed there.

I have to say: this is pretty confusing. The page is called “Workflows”, you’d expect all triggered workflows to appear there, wouldn’t you?

Please consider this as an improvement suggestion. :slight_smile:


#6

Oh, that is weird. All Workflows triggered via commit or tags should be displayed on the Workflows page. Can you please send me the link to your Workflows page so I can investigate this issue? Thanks!


#7

Is this somehow fixed?
I also can’t find any build triggered from a tag in the builds-section.
My config: config.yml

Edit:
I forgot to set the filter also for the checkout-job.
But still can’t see the tag-builds in the workflow-section.


#8

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


#9

#10

Hi there, someone mentioned this thread during my Workflows webinar yesterday, and I wanted to follow up—

Are folks still seeing issues where tag-triggered Workflows runs aren’t appearing in their Workflows UI?

I just tried to reproduce on my end and wasn’t able to, but I’m using a very simple example, so it is possible there’s some kind of bug here…

Build in question: https://circleci.com/gh/iynere/sandbox/274
Workflow in question: https://circleci.com/workflow-run/d270f2b4-89b9-4b67-b376-32b42652dc04

Screenshot of my Workflows page:


#11