Git tag never populating in env variables

I have been trying to push a tag and get different workflow jobs to run based on the existence of the tag.

The git steps I am following are:

I have this already globally set

git config --global push.followTags true

then I run this

git add .
git commit -m 'comment'
git push

You can see below that everything including the are being pushed successfully

To github.com:reponame.git
   cc2123c01b..aa65d415  temp -> temp
 * [new tag]             test.6 -> test.6

However, CIRCLE_TAG is never populated in the environment variables as well as << pipeline.git.tag >> so all jobs always run.

Below is the relevant part of the config.yml

workflows:
  commit:
    jobs:
      - build
      - run-tests:
          requires:
            - build
          filters:
            tags:
              only: /^test.*/

What am I doing wrong, I have read through the docs numerous times and can’t see what I am missing?

Try changing your filter to

filters:
   branches:
      ignore: /.*/
   tags:
     only: /^test.*/

The logic of this which I have only been able to pick up from past posts is that circleci tries to first process a job based on branch info, but when doing so it does not even consider tags. So by ignoring all branches it then focuses on tags.

I tried that, the jobs that contained the ignore didn’t run.

However, even if I do any of the below, they will never trigger:

  • git config --global push.followTags false
  • git tag -a test.9 -m 'test 9'

This means that the tags are never actually reaching any of my workflows. Regardless of whether or not I push a tag, they never run.

OK, as I use bitbucket I do not know github, but I guess one thing to try would be to set a tag on your codebase from directly within the github GUI and see what happens.

I went to the github ui to make a tag. When I got there, all of the tags that I had created were listed there. So there is no question that the tags are there and available. The issue appears to be circleci actually recognizing them.

The reason why I asked you to try that was that CircleCI does not connect to github (or bitbucket) to check the detail - the detail is passed to CircleCI within the webhook request that github sends to CircleCI. This is additionally complicated by limits set by github, which is noted in the CircleCI docs

 https://circleci.com/docs/2.0/workflows

So if you have time, create a new commit without a tag, push it to the server and then tag it via the web GUI. The aim is to find out enough detail so that you can provide the support team with the detail they will need to start looking at the underlying requests.