# Project variable within notification template

**URL:** <https://www.finalbuilder.com/forums/t/project-variable-within-notification-template/6208>\
**Category:** Discussion\
**Created:** [September 26, 2018, 12:20pm UTC](https://www.finalbuilder.com/forums/t/project-variable-within-notification-template/6208 "2018-09-26T12:20:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)\
**Post date:** [September 26, 2018, 12:20pm UTC](https://www.finalbuilder.com/forums/t/project-variable-within-notification-template/6208/1 "2018-09-26T12:20:03Z")

</div>

Hi,

how do i access a project or a configuration variable from within a notification template? I need access to a single value. The list of variables available is not what i need.

Thomas

---

<div class="post-metadata">

**Author:** ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)\
**Post date:** [September 26, 2018, 12:44pm UTC](https://www.finalbuilder.com/forums/t/project-variable-within-notification-template/6208/2 "2018-09-26T12:44:18Z")

</div>

Hi Thomas,

To output the value of a single variable in a template, iterate through the Variables list with a **for** loop and use an **if** statement to select the variable by name. e.g.

```django
{% for variable in Variables %}
   {% if variable.Name == 'Var1' %}{{variable.Value}}{% endif %}
{% endfor %}

```

---

<div class="post-metadata">

**Author:** ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)\
**Post date:** [September 26, 2018, 12:46pm UTC](https://www.finalbuilder.com/forums/t/project-variable-within-notification-template/6208/3 "2018-09-26T12:46:50Z")

</div>

That’s what i was afraid of. Something like Variables[‘myvar’] would be a lot easier to use.

I tested your suggestion before, getting a list of env-vars. Does it actually work for project vars also?

---

<div class="post-metadata">

**Author:** ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)\
**Post date:** [September 26, 2018, 1:08pm UTC](https://www.finalbuilder.com/forums/t/project-variable-within-notification-template/6208/4 "2018-09-26T13:08:53Z")

</div>

We’re restricted to what is available in the [DotLiquid](https://github.com/Shopify/liquid/wiki/Liquid-for-Designers) templating language (although it’s possible that we may be able to extend it… ).

The list should include all variables available in the current scope. The scope would depend on the notification type - for build notification types, this will be build variables which are based on configuration, project and application variables.

---

<div class="post-metadata">

**Author:** ![sa\_thomaslohrum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/ecd19e/32.png) [@sa\_thomaslohrum](https://www.finalbuilder.com/forums/u/sa_thomaslohrum)\
**Post date:** [September 28, 2018, 7:24am UTC](https://www.finalbuilder.com/forums/t/project-variable-within-notification-template/6208/5 "2018-09-28T07:24:01Z")

</div>

Thanks Dave,

i confirm it’s working for me. As templates usually get configured only once and then stay forever 😉 it’s fine. No problem.

Thomas

---

<div class="post-metadata">

**Author:** ![ktopaz](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/ktopaz/32/2390_2.png) [@ktopaz](https://www.finalbuilder.com/forums/u/ktopaz)\
**Post date:** [May 4, 2020, 8:13pm UTC](https://www.finalbuilder.com/forums/t/project-variable-within-notification-template/6208/6 "2020-05-04T20:13:46Z")

</div>

I’m trying to have the selected branch name (used in a configuration input form when queuing the build) show up in the “build started” notification email:

Branch: {% for variable in Variables %}{% if variable.Name == ‘$source.MyRepo.BranchName$’ %}{{variable.Value}}{% endif %}{% endfor %}

But for some reason it always comes empty, i tried with or without the dollar characters.  
Is it possible to use these variables in notifications?

---

<div class="post-metadata">

**Author:** ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)\
**Post date:** [May 5, 2020, 12:24am UTC](https://www.finalbuilder.com/forums/t/project-variable-within-notification-template/6208/7 "2020-05-05T00:24:37Z")

</div>

Hi @ktopaz,

You can not use object expressions (delimited with $) in notification templates. You can only use the variables listed in the info panel on the right of the template editor in the form {{TemplateVariableName}}.

There is no Source collection in the available template variables, but you can use the following template code to get the name of the branch that will be built.

```auto
MyRepo Branch : {%- for change in BuiltChangeSets -%}
{%- if change.RepositoryName == 'MyRepo' -%}{{change.BranchDisplayName}}{%- endif -%}
{%- endfor -%}

```
