Get git tag from my commit

Is there a way to get the git tag related with my commit on my workflow? (yaml or UI)

I would like to commit with a tag (my app version);
trigger a build;
assign the value of my tag to a Bitrise Variable;
and then use that variable to set my version code and version name (currently using the step Set Android Manifest Version Code and Name for that).

That is for the Android version of a Xamarin.Forms app.

Thanks

Hi @joilson-cisne!

Thanks for asking this question here! :slight_smile:

Absolutely! Even better, you don’t have to use a custom step or script to do this, it’s all built into the Trigger Map! (Related blog post: http://blog.bitrise.io/2016/10/15/trigger-builds-with-git-tags.html)

In most cases all you have to do is: add a related Trigger map item in the Triggers section of the Workflow Editor, but depending on the git hosting service and the time you registered your app/webhook you use you might have to change the webhook there a bit (please see the blog post for more details).

You can also find an example trigger config for a use case similar to what you described at: Using the Trigger Map to trigger builds - Bitrise Docs

When a build is triggered by a git tag, you can get the tag from the BITRISE_GIT_TAG environment variable (http://devcenter.bitrise.io/faq/available-environment-variables/), so you don’t have to use a script or any other step to get the tag value, this env var will be set automatically (but only in case the build was triggered by a tag!).

If you’d have any questions, just let us know!

Happy Building! :slight_smile:

1 Like