Git describe --tags

Hello all.

A thing I typically do when pushing (docker) artifacts is to include a tag with the output of git describe --tags --dirty… Its not a functional requirement, its just something that fills me with joy cause I’m a weirdo.

Git has a really nice feature of automatically incrementing a trailing number on the latest tag… (or reflecting a current commit tag)…

So you can always have an incrementing number including a mini sha or the each tag that was pushed.

A Quick example:

Has anyone got any idea how one would do something like this with plugins/Xcr?

I know we can do some nice substitution options: Substitution | Drone

(and I’ve seen ${DRONE_TAG} however I don’t want to demand everyone tags each release/commit)

Is it possible to do a pre-step that sets an example ${GIT_DESCRIBE} that I can use with plugins/ecr for example or is this possibly something that could be added to the plugin?

I assume the bits inside drone that creates DRONE_TAG is not the plugin/ecr so maybe this would have to be integrated into the inner workings of drone?

I’m happy for any ideas about how I could bosh it today and pointers at sections of the drone codebase about where I could possibly PR this kind of support

Hope this makes sense :slight_smile:


Has nobody got any ideas on this subject?

Not sure I understand the question, but if you need to set tags dynamically, you can write comma-separated tags to a .tags file as shown below. When the plugin initializes, it will use the tags file if it exists.

- name: build
  image: golang
    - go build
    - go test
    - echo -n "5.2.6,5.2.4" > .tags

- name: docker  
  image: plugins/ecr
1 Like

This is exactly the solution I was looking for thanks!

(I’ve not seen the .tags feature documented, or maybe I just overlooked that)