# Conditional expression documentation?

**URL:** <https://discuss.circleci.com/t/conditional-expression-documentation/31227>\
**Category:** Build Environment\
**Created:** [July 6, 2019, 3:17am UTC](https://discuss.circleci.com/t/conditional-expression-documentation/31227 "2019-07-06T03:17:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![restapidev](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/restapidev/32/22694_2.png) [@restapidev](https://discuss.circleci.com/u/restapidev)\
**Post date:** [July 6, 2019, 3:17am UTC](https://discuss.circleci.com/t/conditional-expression-documentation/31227/1 "2019-07-06T03:17:39Z")

</div>

I’ve seen posts like the one before showing YAML conditional expressions and it appears to be what I need, but I can’t find any documentation, either circleci specific or yaml, that describes the syntax of **if** expressions. I want to be able to do different things based on the current branch name in the config file rather than in a script file (what I am currently doing). Posts like the one below make it seem like this should be possible in the Circleci config file, but I can’t find any documentation on the syntax. Can someone point me to some?

Posts like this are what lead me to believe conditional commands are possible, or conditional steps (I looked at when/unless, but they can’t use environment variables):

> [@Conditional expressions \[\[... \]\] && work if used with yamal block literals "|"](https://discuss.circleci.com/t/conditional-expressions-work-if-used-with-yamal-block-literals/670/6):
>
> I would probably advise it be changed to a bug report. The error doesn’t seem to make sense, since ; isnt alphanumaric either. Does running your whole circle.yml though [http://www.yamllint.com/](http://www.yamllint.com/) thrown any errors? Im going to guess it wont, but doesnt hurt to check.

Any pointers to documentation on the syntax for such expressions would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [July 6, 2019, 8:00pm UTC](https://discuss.circleci.com/t/conditional-expression-documentation/31227/2 "2019-07-06T20:00:38Z")

</div>

There are a couple of approaches:

1. There is some built in conditional logic in the new 2.1 syntax: [https://circleci.com/docs/2.0/reusing-config/#defining-conditional-steps](https://circleci.com/docs/2.0/reusing-config/#defining-conditional-steps)
2. Things like `[[]]` are bash conditional expressions. You can learn more about that in the bash manual page.

---

<div class="post-metadata">

**Author:** ![restapidev](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/restapidev/32/22694_2.png) [@restapidev](https://discuss.circleci.com/u/restapidev)\
**Post date:** [July 6, 2019, 11:51pm UTC](https://discuss.circleci.com/t/conditional-expression-documentation/31227/3 "2019-07-06T23:51:24Z")

</div>

Ah, I guess I did not realize that, as I am not a bash user. Thanks for the info!

---

<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:** [December 22, 2019, 8:22pm UTC](https://discuss.circleci.com/t/conditional-expression-documentation/31227/4 "2019-12-22T20:22:18Z")

</div>

Closed on December 22, 2019, 8:22pm UTC

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
