Not running job based on filter: tags: only and filter: branch: ignore

This seems like the same exact issue as Build/workflow not triggered when tag is pushed that was solved. I’m not able to see what I’m doing different than the solution.

With the following set up I cannot get the job to build no matter what the tag is or the regex.

job:
  filters:
    tags:
      only: <regex>
    branches:
      ignore: /.*/

When I give a tag for instance 0.0.1-Tquinla92TypescriptReduxUtils, 0.0.1-developerHubHeadless, or 0.0.1-Tquinlan92MaterialCoreUi none of the corresponding jobs (Tquinla92TypescriptReduxUtils, developerHubHeadless, Tquinlan92MaterialCoreUi) run.

My goal is to only run those jobs when the tag matches the regex and it’s on the master build. I’m hoping the if statements I have set up in the jobs will check the branch correctly as it seems like it’s not possible to do via the filters based on what I’ve read. Though I’ve seen numerous people run into the problem I’m having now using a different regex, but I’ve checked my simple regex through a regex testers and those tags should match the filters

Here’s my config

# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2

defaults: &defaults
  docker:
    - image: circleci/node:8

jobs:
  build:
    <<: *defaults 
    steps:
      - checkout

      - run: sudo npm i -g npm

      - run: cd developer-hub-ui && npm ci && npm run build

      - run: cd tquinlan92-material-core-ui && npm ci && npm run build && npm test

      - run: cd tquinlan92-material-core-ui-demo && npm ci && npm run build && npm test

  deployTquinla92TypescriptReduxUtils:
    <<: *defaults
    steps:
      - checkout
      - run:
          name: Publish tquinlan92-typescript-redux-utils
          command: |
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > tquinlan92-material-core-ui/.npmrc
              cd tquinlan92-typescript-redux-utils && npm publish
            fi
  deployDeveloperHubHeadless:
    <<: *defaults
    steps:
      - checkout
      - run:
          name: Publish developer-hub-headless
          command: |
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > tquinlan92-material-core-ui/.npmrc
              cd developer-hub-headless && npm publish
            fi
  deployTquinlan92MaterialCoreUi:
    <<: *defaults
    steps:
      - checkout
      - run:
          name: Publish tquinlan92-material-core-ui
          command: |
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > tquinlan92-material-core-ui/.npmrc
              cd tquinlan92-material-core-ui && npm publish
            fi

workflows:
  version: 2
  build_and_deploy:
    jobs:
      - build:
          filters:
            tags:
              only: /.*/
      - deployTquinla92TypescriptReduxUtils:
          requires: 
            - build
          filters: 
            tags:
              only: /-Tquinla92TypescriptReduxUtils$/
            branches:
              ignore: /.*/
      - deployDeveloperHubHeadless:
          requires: 
            - build
          filters: 
            tags:
              only: /-developerHubHeadless$/
            branches:
              ignore: /.*/
      - deployTquinlan92MaterialCoreUi:
          requires: 
            - build
          filters: 
            tags:
              only: /-Tquinlan92MaterialCoreUi$/
            branches:
              ignore: /.*/

With the above set up if I do a tag of 0.0.1-Tquinla92TypescriptReduxUtils, 0.0.1-developerHubHeadless, or 0.0.1-Tquinlan92MaterialCoreUi none of the deploy jobs run still. I would hope tagging a master commit as 0.0.1-Tquinla92TypescriptReduxUtils would trigger the deployTquinla92TypescriptReduxUtils job

2 Likes

What does happen with the config that you have now?

With the config I have now if I do a tag of 0.0.1-Tquinla92TypescriptReduxUtils, 0.0.1-developerHubHeadless, or 0.0.1-Tquinlan92MaterialCoreUi none of the deploy jobs run.

I want a master commit tagged as 0.0.1-Tquinla92TypescriptReduxUtils to trigger the deployTquinla92TypescriptReduxUtils job for example.

2 Likes

I have the same problem, it’s driving me mad

Same here and it even looks the same in the docs: https://circleci.com/docs/2.0/workflows/#executing-workflows-for-a-git-tag
Filter are set for tag and branches.
Any update what’s going on here?

workflows:
  version: 2
  build:
    jobs:
      - build:
          filters:
            tags:
              only: /^v.*/
            branches:
              ignore: /.*/

I only want to trigger the task when a tag is pushed, not for every commit.
If I remove the filter for branches the job is triggered every time. With this config the job is never triggered. Doesn’t matter if a tag is created or not.

In the job overview is’t also visible that every job is related to a commit and no tag is referenced evver.

1 Like

I have this config and I believe I have achieved what you are after. I can’t quite see how my config is different to yours though, other than having two jobs, with one being dependent on the other. Maybe that has something to do with it?

I ran your config and my config through this parser, and it seems my version tags are getting in a pickle (which I may look into). Despite this, mine works fine - deploys are only done on a deploy- tag prefix.

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