# When: condition not working for tag

**URL:** <https://drone.discourse.group/t/when-condition-not-working-for-tag/10396>\
**Category:** Drone Support\
**Created:** [October 26, 2018, 5:19pm UTC](https://drone.discourse.group/t/when-condition-not-working-for-tag/10396 "2018-10-26T17:19:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rayjlinden](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@rayjlinden](https://drone.discourse.group/u/rayjlinden)\
**Post date:** [October 26, 2018, 5:19pm UTC](https://drone.discourse.group/t/when-condition-not-working-for-tag/10396/1 "2018-10-26T17:19:52Z")

</div>

I’m trying to get drone to deploy to a staging server if a tag is set in git.

I have this:

```auto
pipeline:
  build-and-push-staging-test:
    image: registry.docker/ll-lang/gobuild:1.11-go-workdir
    commands:
      - export BUCKET_NAME=www.test.staging.tilia-inc.com
      - make build BUCKET_NAME=$${BUCKET_NAME} BASE_DOMAIN=test.staging.tilia-inc.com
      - make upload BUCKET_NAME=$${BUCKET_NAME}
    when:
      tag: test-staging*

```

I did set the setting to get tag events. Indeed, I see drone kick off the build. However, the commands associated with this condition do not run. It’s like the when condition is not met. I’m at a loss as to how to debug this. Any ideas?

---

<div class="post-metadata">

**Author:** ![desktophero](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/desktophero/32/3625_2.png) [@desktophero](https://drone.discourse.group/u/desktophero)\
**Post date:** [October 31, 2018, 6:33pm UTC](https://drone.discourse.group/t/when-condition-not-working-for-tag/10396/2 "2018-10-31T18:33:12Z")

</div>

The SCM `event` is the trigger you want. Try changing:

```
when
  tag: something

```

to

```
when:
  event: tag
```

---

<div class="post-metadata">

**Author:** ![yujiangshui](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/yujiangshui/32/4789_2.png) [@yujiangshui](https://drone.discourse.group/u/yujiangshui)\
**Post date:** [February 14, 2019, 2:47pm UTC](https://drone.discourse.group/t/when-condition-not-working-for-tag/10396/3 "2019-02-14T14:47:05Z")

</div>

In the latest version drone v1.0.0, you could use the following `when` configuration to archive this goal.

```auto
when:
      ref:
        include:
          - refs/tags/services/*

```

After that, if you `git tag services/x.x.x` and push to the remote repository, the drone will start work for the tasks.

More detail here: [https://docs.drone.io/config/pipeline/conditions/](https://docs.drone.io/config/pipeline/conditions/) see the By Reference section.
