# Sending a system variable with email

**URL:** <https://community.jenkins.io/t/sending-a-system-variable-with-email/12004>\
**Category:** Ask a question\
**Created:** [January 24, 2024, 8:57pm UTC](https://community.jenkins.io/t/sending-a-system-variable-with-email/12004 "2024-01-24T20:57:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wesleywestfd](https://avatars.discourse-cdn.com/v4/letter/w/22d042/32.png) [@wesleywestfd](https://community.jenkins.io/u/wesleywestfd)\
**Post date:** [January 24, 2024, 8:57pm UTC](https://community.jenkins.io/t/sending-a-system-variable-with-email/12004/1 "2024-01-24T20:57:52Z")

</div>

Hello, I am trying to send a email with a system variable in the post build actions. I am using Editable email notification

In the subject line I am using ${ENV,var=“DTEE”} which DTEE is the system variable and I verified it is being set but when the email is send the subject is just blank. Any help would be great!

Thanks in advance

---

<div class="post-metadata">

**Author:** ![slide\_o\_mix](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/slide_o_mix/32/20977_2.png) [@slide\_o\_mix](https://community.jenkins.io/u/slide_o_mix)\
**Post date:** [January 24, 2024, 9:20pm UTC](https://community.jenkins.io/t/sending-a-system-variable-with-email/12004/2 "2024-01-24T21:20:36Z")

</div>

When you say “system variable” do you mean system environment variable? Just want to make sure. As an FYI, the ENV does not look at normal system environment variables, only Jenkins environment variables.

---

<div class="post-metadata">

**Author:** ![wesleywestfd](https://avatars.discourse-cdn.com/v4/letter/w/22d042/32.png) [@wesleywestfd](https://community.jenkins.io/u/wesleywestfd)\
**Post date:** [January 24, 2024, 9:33pm UTC](https://community.jenkins.io/t/sending-a-system-variable-with-email/12004/3 "2024-01-24T21:33:32Z")

</div>

Yes, sorry. I set a system environment variable during the process.

---

<div class="post-metadata">

**Author:** ![slide\_o\_mix](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/slide_o_mix/32/20977_2.png) [@slide\_o\_mix](https://community.jenkins.io/u/slide_o_mix)\
**Post date:** [January 25, 2024, 5:35pm UTC](https://community.jenkins.io/t/sending-a-system-variable-with-email/12004/4 "2024-01-25T17:35:23Z")

</div>

One thing to note is that system environment variables set during an sh/bat/pwsh step are not retained after that step completes. Each sh/bat/pwsh step is its own process, so the env variables are not maintained across. Also, the token-macro-plugin (which email-ext uses for token replacement) does not support system environment variables for the ENV token.

---

<div class="post-metadata">

**Author:** ![wesleywestfd](https://avatars.discourse-cdn.com/v4/letter/w/22d042/32.png) [@wesleywestfd](https://community.jenkins.io/u/wesleywestfd)\
**Post date:** [January 25, 2024, 5:39pm UTC](https://community.jenkins.io/t/sending-a-system-variable-with-email/12004/5 "2024-01-25T17:39:05Z")

</div>

I actually figured it out. Seems like a bug but who knows

I set the system variable in windows and I run my test, The variable doesn’t show anything with ${ENV,var=“DTEE”} but if I restart jenkins and run the test it now emails 01/25/2024. I then change the variable from windows and run the test and it remains the same but if I restart jenkins and run the test the variable in the email now matches the new value. Looks to me like it only picks up on the system variables during startup…

Thank you very much for your help!
