# Regex matches within YML configuration

**URL:** <https://discuss.circleci.com/t/regex-matches-within-yml-configuration/8630>\
**Category:** Deployments\
**Tags:** deployment, circle-yml\
**Created:** [December 12, 2016, 1:14pm UTC](https://discuss.circleci.com/t/regex-matches-within-yml-configuration/8630 "2016-12-12T13:14:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![g105b](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/g105b/32/13561_2.png) [@g105b](https://discuss.circleci.com/u/g105b)\
**Post date:** [December 12, 2016, 1:14pm UTC](https://discuss.circleci.com/t/regex-matches-within-yml-configuration/8630/1 "2016-12-12T13:14:07Z")

</div>

Hi there,

Within circle.yml, I use regular expressions to match tag names in the format “v1.2.3”.

```
deployment:
  production:
    tag: /(v[0-9]\.[0-9]\.[0-9])/
    commands:
      - ./deploy.sh production $tag

```

I need the [deploy.sh](http://deploy.sh) script to know what tag is currently matched, but referring to it as $tag doesn’t pass the tag name to the script. Is there a way to do this?

---

<div class="post-metadata">

**Author:** ![FelicianoTech](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/felicianotech/32/21348_2.png) [@FelicianoTech](https://discuss.circleci.com/u/FelicianoTech)\
**Post date:** [December 12, 2016, 4:44pm UTC](https://discuss.circleci.com/t/regex-matches-within-yml-configuration/8630/2 "2016-12-12T16:44:17Z")

</div>

Try `CIRCLE_TAG` as mentioned here: [https://circleci.com/docs/1.0/environment-variables/#build-details](https://circleci.com/docs/1.0/environment-variables/#build-details)

Hopefully that meets your needs. 🙂

---

<div class="post-metadata">

**Author:** ![g105b](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/g105b/32/13561_2.png) [@g105b](https://discuss.circleci.com/u/g105b)\
**Post date:** [December 12, 2016, 4:47pm UTC](https://discuss.circleci.com/t/regex-matches-within-yml-configuration/8630/3 "2016-12-12T16:47:54Z")

</div>

Ah, ok, so instead of trying to match the regex I just need to switch between CIRCLE\_BRANCH and CIRCLE\_TAG.

Thanks for pointing that out to me… looks like I was barking up the wrong tree!

Cheers,  
Greg.

---

<div class="post-metadata">

**Author:** ![FelicianoTech](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/felicianotech/32/21348_2.png) [@FelicianoTech](https://discuss.circleci.com/u/FelicianoTech)\
**Post date:** [December 12, 2016, 5:10pm UTC](https://discuss.circleci.com/t/regex-matches-within-yml-configuration/8630/4 "2016-12-12T17:10:16Z")

</div>

Well you still need to regex part if you want the deploy section to trigger based on tags. I’m saying that instead of passing `$tag` to the deploy script, pass `$CIRCLE_TAG`.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:41am UTC](https://discuss.circleci.com/t/regex-matches-within-yml-configuration/8630/5 "2018-06-18T11:41:09Z")

</div>


