Jenkins - sending email after build with the build version as a subject I would like to send an email at the end of my build to inform success or failure. I'm using the email ext-plugin for Jenkins. I want the version number of the build to be the subject of the email.

The problem is that the version is something that changes in each build, so I need to somehow edit an environmental variable to hold the version number each time (I have a script that saves it into a file). This is the default configuration: 


I would like to have, for example, set the version number into a variable using windows batch script, like this:

rem # Loading version File number
set MY_BUILD_VERSION=&lt;myVersionFile.txt
rem # Loading content
set MY_BUILD_CONTENT=&lt;myContentFile.txt


And using it in the email plugin, like this:


The problem is that the environmental variables aren't recognized outside the .bat file they are being run from, although I'm using the envInject plugin, the documentation says that what's run from a script won't be recognized outside of it.

Is there any way to load data into the email plugin from a file, or any other dynamic way to load my version number dynamically?
I found a way to set environmental variables globally from a file!
I'm using envInject for loading variables from a file.

For example, lets say I have a file that is called "versionNumber.txt" and that it's created during the build process. Maybe I update it in every build, or any other way. then I create a prosFile that can be identified by the envInject, by running a batch script:

set /p VERSION_NUM=&lt;versionNumber.txt


Let's assume my version number was 1.5.5.10. so now my VERSION_NUM equals that string.
now VERSION_NUM has the value that I want. But it's local, it won't help me. so I rewrite it to a file in the following format (also, using a batch script):

echo VERSION_NUM=%VERSION_NUM% &gt; C:\Temp\prosFile


now I have a file that contains the following content:

VERSION_NUM=1.5.5.10


And now I just need to load the file using the envInject plugin:



And now I have an environmental variable named VERSION_NUM that can be used anywhere in Jenkins. But I wanted to make it the subject of my email, so I'll simply do (in windows, in linux it might be different):



That's it!