Git tag deploys in 2.0


#1

How can I use git tags to deploy ? like https://circleci.com/docs/configuration/#tags


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

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


#3

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.


#4

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]\+$";
    then
      version=$(git log -1 --pretty=%B)
      docker build -t foo/bar:$version .
    else
      echo "Not a release, skipping build"
    fi

#5

@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.


#6

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


#8

EDIT: full Git tag support is now available on CircleCI 2.0. See: https://circleci.com/docs/2.0/configuration-reference/#tags


Build on tag
#9

@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.


#10

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


#11

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


#12

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.

.circleci/config.yml:

# Deploy to staging for git tags prefixed with 'qa-'
deployment:
  qa_deploy_staging:
    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!


#13

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


#14

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


#15

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.


#16

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?


#17

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


#18

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.


#19

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


#20

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.


#21

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

deployment:
  trigger_tag:
    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