Running git tag after each build


#1

Hi,
This might sound weird, but is there a way to make drone create a new git tag every time a build is successful?
I saw a lot of tagging for the docker image, but was wondering if this can be possible


Pushing a git tag to Github in a plugin
#2

This might sound weird, but is there a way to make drone create a new git tag every time a build is successful?

Yes, you can execute a git tag and push directly from your commands section (see below)

pipeline:
  build:
   ...
  tag:
    image: docker:git # this image has git installed
    commands:
      - git tag vX.Y.Z
      - git push origin vX.Y.Z

Note that if your repository is public, you will need to provide a way to authenticate the git+https push. This can be done creating a drone secret [1] that includes a username/password or oauth token that you can provide to the git command.

I saw a lot of tagging for the docker image

This tagging is being performed by a plugin, which is essentially just executing shell commands under the covers [2]. You could encapsulate the above shell commands in a plugin, if you really wanted.

[1] http://docs.drone.io/manage-secrets/
[2] http://docs.drone.io/creating-custom-plugins-bash/


#3

Hi @bradrydzewski,
Thanks for the quick response.

Sorry, what I tried to say is that I searched for how to do tagging, but all the searches was regarding docker tagging and not what I hoped to find out.
I will try to see if I can manage to use that.

Since it’s very common to perform docker tags, another quick question would be is it recommended what I am trying to accomplish or would the docker tagging suffice?

Thanks.


#4

Sorry, I’m not sure I understand the question, since Docker tagging and git tagging are separate things. If you want to push a git tag to your remote, I do not believe the Docker plugin is relevant here. The Docker plugin is used to build, tag and push Docker images to Dockerhub, which is a different use case.


#5

Yeah, sorry for the confusion.
Managed to perform the tagging successfully with the provided steps.

Thanks a lot. Have a good one!