Treat tags the same as branches


When I create a new branch in git-hub circle-ci magically notices and builds it. It would be great if it did exactly this for tags as well.

Essentially, my build generates various artefacts which I haven’t figured out how to push back to git-hub yet. If builds were also trigged by tags then my problem would be solved as users who need the artefacts could simply click on the appropriate tag.

I can get exactly what I want now by using branches instead of tags, but that is irksome :slight_smile:


We actually do trigger for tags as described here. The difference is that tags do not trigger builds by default, and the build will only be run if there is a deployment section that matches the tag that has been created / pushed.


Thanks Alexey. I don’t want to deploy anything though - is the following fragment sufficient:

    tag: /release-.*/
    owner: circleci```

or must I do:

    tag: /release-.*/
    owner: circleci
    - ./```


The behaviour with an empty commands section is undefined, so you’ll have to specify at least something to run there. But a simple true would suffice:

    tag: /release-.*/
    owner: circleci
      - "true"

EDIT: added quotes around the true command, as otherwise YAML interprets that as a boolean while CircleCI expects a command. Thanks @yatesco for pointing it out.


Thanks Alexy.


Actually, this isn’t working. At least, with the following circle.yml pushing a tag does nothing:

    version: oraclejdk8

 ## Customize dependencies
    - "~/.m2"

    - lein full-build!
    - mkdir -p $CIRCLE_TEST_REPORTS/junit/
    - find . -type f -regex ".*/target/test-reports/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;

    - "target/*.war"

    tag: /v[0-9]+(\.[0-9]+)*/
    owner: circleci
      - (true)

(NOTE: I had to use (true) rather than true otherwise the build failed)


Could you please give us the name of the tag that you pushed? I’d like to try to reproduce it in my sample project.


Hi Alexey - I replied to your email with the private links - would you prefer a public repo demoing the behaviour?


Sorry, I don’t think I have received the links. Would it be possible to replicate the behaviour with a public project? Thank you very much for your effort.


Hi Alexey, I just received a bounced email :-).

The tag was v1.0.2 and v1.0.3 but I will try and reproduce in a public project when I get time (probably not for the next week or two)


Thanks @yatesco, will be waiting for your follow-up.


The tag regexp based deployment is not working for me. I was ssh-ing into the build machine, and realized, that the checkout step doesn’t pulls the tags …

I’m not sure about the implementation details about the checkout. Is it shell-ing to: git checkout, or its using the github api directly?

Anyway, my workaround was to add a pre step, to fetch the tags:
dependencies: pre: - git fetch --tags


Thanks lalyos, so does pushing a tag cause a new ci-build and does that tag appear in the list on circle-ci?


adding - git fetch --tags is not working as well. tags are not triggering a new build


after all got it to work. it doesn’t show the build under the branch the tag was made on and you can’t define branch and tag for the same deployment. which is what I actually need.


@alexey I’ve followed the documentation to trigger a build only on a matching tag, buy first whitelisting the branch name to a fake name that never exists (so that no regular commits to any branch will trigger a build). Then I added the tag option under deploy with a regex that matches the tag name. According to docs, the tag will trigger a build because it matches the tag. But in reality, a matching tag ‘v1.0.0’ simply gets marked as ‘not run’.

      - nonExistantBranch
    tag: /v[0-9]+(\.[0-9]+)*/
      - do some stuff


Sorry for the delay here.

I assume that it has to do with the branch ignore mechanism. I will file a bug on this, in the meanwhile we’ll have to look for a different solution.

One question: per your development workflow, do you always tag contents of different branches? Or the code that gets deployed is always on the master branch? If it is on master, you could probably only ignore the master branch—and this should work around the issue.


This should be fixed now. Could you please try running builds like that again?


Hi Alexey, tagged bulids still don’t seem to work. Even just using the example on the config page still no build is triggered.


You are referring to this example in the docs, is that right? I cannot reproduce the issue locally—would you mind posting all the sections of your current circle.yml here, except for machine, dependencies, and test? Thanks.