# \[ANSWERED\] Does $DRONE\_TAG get set for ref triggered builds?

**URL:** https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258
**Category:** Drone Support
**Created:** [October 16, 2020, 8:04am UTC](https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258 "2020-10-16T08:04:06Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![aknudsen](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/aknudsen/32/5067_2.png) [@aknudsen](https://drone.discourse.group/u/aknudsen)
#### Post date: [October 16, 2020, 8:04am UTC](https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258/1 "2020-10-16T08:04:06Z")

</div>

The [documentation](https://docs.drone.io/pipeline/environment/reference/drone-tag/) for $DRONE\_TAG is rather weak - is it supposed to be set only for _tag_ events (and “promotion events that are derived from tags”)? We need to get the tag for [ref](https://docs.drone.io/pipeline/triggers/#by-reference) triggers also, and luckily, AFAICT $DRONE\_TAG is actually available for these builds too (only based on observing one build as of yet).

Can you please clarify if $DRONE\_TAG is also supposed to be set for _ref_ triggered builds, where the ref is a tag? If so, also update the documentation please. We really need $DRONE\_TAG in combination with the ref trigger (provided that the ref is a tag of course), since we can’t filter tag events.

---

<div class="post-metadata">

### Author: ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)
#### Post date: [October 16, 2020, 12:36pm UTC](https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258/2 "2020-10-16T12:36:02Z")

</div>

`DRONE_TAG` is populated when the `ref` field starts with `refs/tags/`. The ref field comes from the GitHub webhook.

> <https://github.com/drone/runner-go/blob/master/environ/environ.go#L178:L183>

---

<div class="post-metadata">

### Author: ![aknudsen](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/aknudsen/32/5067_2.png) [@aknudsen](https://drone.discourse.group/u/aknudsen)
#### Post date: [October 16, 2020, 12:57pm UTC](https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258/3 "2020-10-16T12:57:29Z")

</div>

Many thanks for confirming that @bradrydzewski! Would you mind updating the $DRONE\_TAG [docs](https://docs.drone.io/pipeline/environment/reference/drone-tag/) to reflect this? Would appreciate it, to help the future me and others 🙂 I mean, currently the docs give the impression the variable won’t be set for ref triggered builds.

---

<div class="post-metadata">

### Author: ![ashwilliams1](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/ashwilliams1/32/5549_2.png) [@ashwilliams1](https://drone.discourse.group/u/ashwilliams1)
#### Post date: [October 16, 2020, 1:28pm UTC](https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258/4 "2020-10-16T13:28:13Z")

</div>

I will see what we can do to clarify, however, I believe the docs are technically accurate. There are only six types of events in the system (push, pull\_request, tag, cron, rollback and promote). These events are determined by the incoming webhook that we receive from GitHub and correspond to the webhook event type. The _ref_ filter in the _trigger_ section of the yaml and the _event_ are different, unrelated data types.

---

<div class="post-metadata">

### Author: ![aknudsen](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/aknudsen/32/5067_2.png) [@aknudsen](https://drone.discourse.group/u/aknudsen)
#### Post date: [October 16, 2020, 1:34pm UTC](https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258/5 "2020-10-16T13:34:20Z")

</div>

I’m not exactly sure what you mean @ashwilliams1.

Reading the $DRONE\_TAG documentation it gives the impression that only tag and promotion (“derived from tags”) [trigger events](https://docs.drone.io/pipeline/triggers/#by-event) cause $DRONE\_TAG to be set. It turns out however, it will also be set for the ref trigger, if corresponding to a tag (which is good!).

So, basically reading the $DRONE\_TAG documentation, it gives the reader the impression it only applies to tag and promotion _trigger events_. If you operate with a different notion of event in this documentation, you should be explicit as you can’t expect the reader to have the same understanding.

---

<div class="post-metadata">

### Author: ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)
#### Post date: [October 16, 2020, 1:38pm UTC](https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258/6 "2020-10-16T13:38:59Z")

</div>

I think we should rename `trigger` to `when` in the yaml (note that we would of course make this backward compatible). The current naming is misleading and can cause confusion. A build is triggered by a webhook or by the user action of promoting or rolling back a build. It would be more accurate to describe the _trigger_ section of the yaml as a filter, since it is not actually trigging a build. Renaming should help eliminate any confusion.

---

<div class="post-metadata">

### Author: ![aknudsen](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/aknudsen/32/5067_2.png) [@aknudsen](https://drone.discourse.group/u/aknudsen)
#### Post date: [October 16, 2020, 1:40pm UTC](https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258/7 "2020-10-16T13:40:37Z")

</div>

I don’t personally see how renaming _trigger_ would help in this case. The confusion arises from the difference between webhook events Drone is dealing with and trigger events you can use in your configuration. As I already wrote, when I read $DRONE\_TAG documentation, I thought instinctively that “event” referred to trigger events, until @ashwilliams1’s pointing out that event here refers to Drone’s internal notion (stemming from a webhook).

---

<div class="post-metadata">

### Author: ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)
#### Post date: [October 16, 2020, 1:41pm UTC](https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258/8 "2020-10-16T13:41:15Z")

</div>

renaming should help eliminate confusion, since there is no such thing as a trigger event. The trigger section in the yaml is a filter, and should be renamed to reflect its true purpose.

---

<div class="post-metadata">

### Author: ![aknudsen](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/aknudsen/32/5067_2.png) [@aknudsen](https://drone.discourse.group/u/aknudsen)
#### Post date: [October 16, 2020, 1:43pm UTC](https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258/9 "2020-10-16T13:43:11Z")

</div>

It wouldn’t help me. What I mean by trigger event is the option to [trigger on an event](https://docs.drone.io/pipeline/triggers/#by-event).

The “trigger” part isn’t causing the confusion, but the “event” option since it’s orthogonal to triggering by “ref” (thus giving me the impression that $DRONE\_TAG wouldn’t be set when triggering on “ref”).

---

<div class="post-metadata">

### Author: ![aknudsen](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/aknudsen/32/5067_2.png) [@aknudsen](https://drone.discourse.group/u/aknudsen)
#### Post date: [October 16, 2020, 1:45pm UTC](https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258/10 "2020-10-16T13:45:42Z")

</div>

It’s quite possible that “trigger” should be renamed, but it doesn’t relate to the confusion from the $DRONE\_TAG docs I’m trying to point out.

---

<div class="post-metadata">

### Author: ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)
#### Post date: [October 16, 2020, 1:50pm UTC](https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258/11 "2020-10-16T13:50:06Z")

</div>

we will make changes to ensure the system is more intuitive. I am going to mark this as resolved, since the question has been answered.

---

<div class="post-metadata">

### Author: ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)
#### Post date: [October 16, 2020, 1:50pm UTC](https://drone.discourse.group/t/answered-does-drone-tag-get-set-for-ref-triggered-builds/11258/12 "2020-10-16T13:50:23Z")

</div>


