# Device variable for current/target release

**URL:** <https://forums.balena.io/t/device-variable-for-current-target-release/31498>\
**Category:** Product support\
**Created:** [September 8, 2019, 8:09pm UTC](https://forums.balena.io/t/device-variable-for-current-target-release/31498 "2019-09-08T20:09:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![klatr](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@klatr](https://forums.balena.io/u/klatr)\
**Post date:** [September 8, 2019, 8:09pm UTC](https://forums.balena.io/t/device-variable-for-current-target-release/31498/1 "2019-09-08T20:09:07Z")

</div>

Hi  
Is it possible to get the current deployment and target release as device environment variable? According this list ([https://www.balena.io/docs/learn/manage/configuration/](https://www.balena.io/docs/learn/manage/configuration/)) and when list all variables (`env`) the release is not there.

Are there any plans to add this?

Thanks

---

<div class="post-metadata">

**Author:** ![dfunckt](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dfunckt/32/56_2.png) [@dfunckt](https://forums.balena.io/u/dfunckt)\
**Post date:** [September 9, 2019, 7:35am UTC](https://forums.balena.io/t/device-variable-for-current-target-release/31498/2 "2019-09-09T07:35:50Z")

</div>

I think these indeed aren’t exposed as envvars, you can however user the Supervisor API to get them as described here: [https://www.balena.io/docs/reference/supervisor/supervisor-api/#get-v2applicationsstate](https://www.balena.io/docs/reference/supervisor/supervisor-api/#get-v2applicationsstate)

---

<div class="post-metadata">

**Author:** ![klatr](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@klatr](https://forums.balena.io/u/klatr)\
**Post date:** [September 9, 2019, 2:50pm UTC](https://forums.balena.io/t/device-variable-for-current-target-release/31498/4 "2019-09-09T14:50:07Z")

</div>

Thanks for replying.  
Using the supervisor api might be a solution (workaround) for accessing current application state. But when using the same code outside of balena a API call is not possible but setting envvars.

Probably you can take this as an idea for your roadmap? 😃

---

<div class="post-metadata">

**Author:** ![thgreasi](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thgreasi/32/454_2.png) [@thgreasi](https://forums.balena.io/u/thgreasi)\
**Post date:** [September 9, 2019, 5:48pm UTC](https://forums.balena.io/t/device-variable-for-current-target-release/31498/5 "2019-09-09T17:48:38Z")

</div>

Hi,  
I will open an internal issue with your suggestion on exposing the current release hash as an env var.  
On the other hand doing so for the target release is probably harder to do, since that would require a container restart every time the target release changes.  
For now, in order to have a unified handling, you could probably have your container’s startup script to check whether the code is running on a balena device and if so use the supervisor api and set an env var.

---

<div class="post-metadata">

**Author:** ![klatr](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@klatr](https://forums.balena.io/u/klatr)\
**Post date:** [September 10, 2019, 4:51pm UTC](https://forums.balena.io/t/device-variable-for-current-target-release/31498/7 "2019-09-10T16:51:03Z")

</div>

Many thanks for your suggestions. By now the current release would be enough as I like to track my generated data to each device and release. So far the target is not really necessary for me.
