Circleci builds are not triggered on creating a tag on github

Here is my config.yaml

  version: 2.1
  executors:
    docker-publisher:
      environment:
        IMAGE_NAME: mocking-service
      docker:
        - image: circleci/buildpack-deps:stretch
  jobs:
    build:
       executor: docker-publisher
       steps:
         - checkout
         - setup_remote_docker
         - run:
            name: Build Docker image
            command: |
              docker build -t $NEXUS_REPO/$IMAGE_NAME:latest .
         - run:
            name: Archive Docker image
            command: docker save -o mocking.tar $NEXUS_REPO/$IMAGE_NAME
         - persist_to_workspace:
              root: .
              paths:
                - ./mocking.tar
    publish-latest:
      executor: docker-publisher
      steps:
        - attach_workspace:
            at: /tmp/workspace
        - setup_remote_docker
        - run:
            name: Load archived Docker image
            command: docker load -i /tmp/workspace/mocking.tar
        - run:
            name: Show images
            command: docker images
        - run:
            name: Publish Docker Image to Nexus
            command: |
                  docker login --username=$NEXUS_USERNAME --password=$NEXUS_PASSWORD $NEXUS_REPO
                  docker push $NEXUS_REPO/$IMAGE_NAME:latest
  workflows:
    version: 2
    build-and-publish-image-to-nexus:
      jobs:
        - build:
            filters:
              tags:
                only: /^tag-*/
        - publish-latest:
            requires:
              - build
            filters:
              tags:
                only : /^tag-*/
              branches:
                ignore: /-*/

can some one help me with why my builds are not triggered on pushing the tag. I checked the web hooks on github and they look perfectly fine to me and my tag name always starts with β€˜tag-’

I tried to use this solution but no luck Build/workflow not triggered when tag is pushed

I think your regex is not correct. Can you make it /^tag-.*/ instead. It looks -* matches any number of - when I belive you are trying to match all the way to the end of the string.

1 Like

Also, fwiw I am not a regex expert (regexpert?). I used this site to test it out.

2 Likes

Thanks a lot. That solved my problem!!

2 Likes

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