No workflow when I set filters to only tags and ignore all branches

Hello !
I’m trying to run a workflow only on tags But I’m getting no workflow
And when I remove ignore branches it runs on every branche & tag
Do I miss somthing ? or what exactly can I achive this usecase.
This is a screenshot and I’m expecting the workflow to run on instable-2.7.31.
Thanks.

My config.yml

only-deploy-unstable: &only-deploy-unstable
  context: Unstable-context
  filters:
    tags:
      only: /^unstable-.*/
    branches:
      ignore: /.*/

version: 2.1

jobs:
  build_unstable:
    docker:
      - image: docker:20.10.8
    environment:
      DOCKER_IMAGE_BASE_URL: **********
    steps:
      - checkout
      - setup_remote_docker
      - run: apk update
      - run: apk add git
      - run: docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
      - run:
          name: build and push unstable docker image
          no_output_timeout: 15m
          command: |
            export TAG_NAME=$(git describe --tags --abbrev=0)
            echo ${DOCKER_IMAGE_BASE_URL}:$TAG_NAME
            docker build  --build-arg STAGING=test --rm -t $DOCKER_IMAGE_BASE_URL:$TAG_NAME -t $DOCKER_IMAGE_BASE_URL:latest .
            docker push $DOCKER_IMAGE_BASE_URL:$TAG_NAME
            docker push $DOCKER_IMAGE_BASE_URL:latest
  deploy_unstable:
    docker:
      - image: docker:20.10.8
    steps:
      - checkout
      - setup_remote_docker
      - run: command -v ssh-agent >/dev/null || ( apk add --update openssh )
      - run: eval $(ssh-agent -s)
      - run: ********************

workflows:
  # build unstable-version 
  
  build_and_push_unstable:
    jobs:
      - build_unstable: *only-deploy-unstable
      - hold:
          <<: *only-deploy-unstable
          type: approval
          requires:
            - build_unstable
      - deploy_unstable:
          <<: *only-deploy-unstable
          requires:
            - hold

Hello

I have taken your config and when running it myself using the same settings it is working as it should and using the same tag as you triggers the build.

Would it be possible to raise a support ticket for our team to look into this for you.

https://support.circleci.com/hc/en-us/requests/new

Kind Regards

1 Like

@owenoliver1 Thank you for your reply!
I kept trying all week. And suddenly, this morning the config starts working as it should! Mybe there was an update!
And thank you again :smile:

I’m facing this issue again this morning.

Now, this is going to sound strange, but have you tried unwrapping your use of Node Anchors?

My reasoning is that many users of CircleCI are using tags and so have jobs that depend on the same filter structure you have basically turned into a macro, but there have been few reports of problems. So I am wondering if the issue is more to do with the YAML parser.

Beyond that, it will need a support issue raised - while end users can see a certain amount of debugging information when a job runs and fails we do not have access to any details of what has happened to cause a job not to run in the first place.

@rit1010
Yeah I tried and I get the same behavior and result.
I think, my problem in the regex
Because I set a trigger from the UI in the project settings

Parameter condition Value Result
Tag matches (regex) /^stable.*/ not trigger the job :stop_sign:
Tag = (equals) stable-1.0.33 this trigger the job :white_check_mark:

Screenshots

One answer may be to change the regex from using a * to a structure that is matching something like

/^stable-[0-9].[0-9].[0-9]+/

and then see if you get matches taking place. Another way to write this is maybe

/^stable-\d.\d.\d+/

but that type of formatting gets hard to read fast.

1 Like

@rit1010 Thanks again for your answer.

I tried so many combinations, even with /.*/ but no luck.
This is so confusing. I don’t know why exactly this is not working because it’s a basic configuration setup.

I’ve tested so many use cases, and I found out that regex works with branches but not with tags !

Parameter condition Value Result
branch = (equals) test/1 this triggers the job :white_check_mark:
branch matches (regex) /^test.*/ this triggers the job :white_check_mark:
Tag matches (regex) /.*/ not triggers the job :stop_sign:
Tag matches (regex) /^stable.*/ not triggers the job :stop_sign:
Tag matches (regex) /^stable-[0-9].[0-9].[0-9]+/ not triggers the job :stop_sign:
Tag matches (regex) /^stable-\d.\d.\d+/ not triggers the job :stop_sign:
Screenshot


My simple config that should work only on tags

version: 2.1
executors:
  executor-linux-small:
    docker:
      - image: cimg/base:2020.01
    resource_class: small

jobs:
  job-hello-world-2:
    executor: executor-linux-small
    steps:
      - run: echo "hello world"

workflows:
  version: 2
  build_and_deploy_unstable:
    jobs:
      - job-hello-world-2:
          filters:
            tags:
              only: /^stable.*/
              # only: /^stable-\d.\d.\d+/
            branches:
              ignore: /.*/

Thanks.

Well with all those tests it is clear there is nothing more you can do at your end so it is going to need staff members to look at the issue on the server and/or within the source code.

1 Like

Hi @amjadbouhouch,

Thank you for sharing your question on our forum.

I tested this out on my end, and found that you will need to specify the regex like the following:

^stable.*$

where the regex will match the full tag name (including $ at the end).

For other users, I would like to point out that the trigger setting for tags is only available in the UI for Gitlab projects currently.

Then in your config.yml file itself, it would look like this:

workflows:
  workflow1:
    jobs:
      - build:
          filters:
            tags:
              only: /^stable.*$/
            branches:
              ignore: /^.*$/

Could you try this out and let me know if it works?

1 Like

Hi @aaronclark, and thank you for your support.

Unfortunately, this is still not working for me.

But I found a solution where I set the trigger to EventType = Push Tag like so.

And my config.yml file looks like this:

build_and_deploy_stable:
    jobs:
      - build_stable:
          filters:
            tags:
              only: /^stable.*$/
            #branches:  If I set branches to  ignore all - the flow will not trigger
              #ignore: /^.*$/
          context: app-context
      - hold_stable:
          filters:
            tags:
              only: /^stable.*$/
          type: approval
          requires:
            - build_stable
      - deploy_stable:
          filters:
            tags:
              only: /^stable.*$/
          context:
            - app-context
            - aws-context
          requires:
            - hold_stable