Sending a system variable with email

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

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.

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

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.

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!