Git tag deploys in 2.0


How can I use git tags to deploy ? like

No build triggered when I commit with a tag on bitbucket
Getting Started: Configuration

maybe same question I asked here: What are the other steps for the yaml file?


We do not yet have support for git tags in the 2.0 deploy. In the meantime, you can likely use the git describe output with an if statement.


Here’s what we do - our tagged releases also have a version number in the commit message, e.g. 1.5.0. Here’s an example we use that checks for last commit message and if it matches a version release, we build the Docker image.

- type: setup-docker-engine

- type: shell
  name: Build docker image
  command: |
    if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
      version=$(git log -1 --pretty=%B)
      docker build -t foo/bar:$version .
      echo "Not a release, skipping build"


@rohara I understand how to parse tags in 2.0, but is there no functionality for initiating builds from tags and/or releases from GitHub? After migrating a project to 2.0, we are not seeing builds for tagged releases.


Not at this time but there is an open ticket about it internally. The tag support is brand new in general in 2.0.


EDIT: full Git tag support is now available on CircleCI 2.0. See:

Build on tag

@rohara thanks for letting me know the team is on it.

@tom that example is actually super helpful, thank you, but I think we will have to wait on proper tag support (or even just triggering builds - I’m ok with parsing tags within the build, just need the build to actually start) before we can move our project to 2.0.

Appreciate the responses. Hope to get this project on 2.0 ASAP and so far as I know, this is the last blocker for us.


The workaround means that builds will start whenever tags of your choosing are pushed to GitHub.


I understand, and I’d rather wait until the feature is properly implemented rather than temporarily hacking it. Appreciate the workaround though.


NOTE - this workaround is no longer supported

@tom is fake_deploy_for_cci2 a required name? I followed the workaround convention but modified fake_deploy_for_cci2 to my liking and changed the tag and commands values, and my tagged builds are still not triggering in CircleCI 2.0.


# Deploy to staging for git tags prefixed with 'qa-'
    tag: /qa-.*/
    commands: |
        mkdir -p src/assets /web/coverage

My tag has been pushed to GitHub as qa-feature/DEV....

(clearly I’ve caved to the workaround as it’s holding us back)

EDIT: I’ve realized my mistake - reading too quickly. Thanks, all. I think this will work for us for now. We would still love to be updated if anything involving this workaround (or the official implementation) changes!


Glad you got it working. We’ll be sure to update when new features are available in this area.


Just chiming in here - this issue is also blocking us from upgrading to 2.0.


Thanks for the info guys. We’ve been using 2.0 for a little while now, and I just tried to cut a new release through a tag and found this!

We’ll use the if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; method for now. Thanks for the suggestion.


Thanks for the workaround @tom! It worked great until we started using workflows. Now the builds fail with job 'build' is not found, which is sort of true because our jobs are called build_airflow and build_product. It seems it tries to queue a build, while we would need it to queue a workflow. Do you have any ideas on how we could work around this? Or an ETA on proper tag support?


I am baffled as to why the syntax needed to be completely changed and functionality limited. The workaround from @tom gets messy anyway if you have multiple tags that perform different steps. Very very odd design pattern.

Appreciate the work though especially on the dockerisation


The workaround does not seem to trigger on tags that are created by Github releases. When I create a tag locally and push it I see the build happen. I’m using the Github API to create a release and see that the webhook is firing.


It looks like Github releases use lightweight tags instead of annotated tags. @tom Does CircleCI only support kicking off builds from annotated tags?


Thanks for the feedback everyone. We’re working on implementing full Git tag support for 2.0. We needed to wait for Workflows to make sure it would work for all use cases.

I’ve let the dev team know to be sure to support annotated and lightweight tags for GitHub releases.

I don’t have an ETA for when this will land, but we’ll update here when it does.


I add this code to my config v2 and it works to run the build steps:

    tag: /.*/

But f you add the commands option it is not run as excepted.

Can have a confirmation from CircleCI that this solution is stable and will be not deleted in the future ? Or any update about a future option to active build on tag that could be great.

Build on tag