Passing variable from shell to email-ext in Jenkins

jenkins email-ext variables
jenkins pipeline email-ext example
jenkins email-ext attachment example
jenkins pipeline email template variables
jenkins email content from file
jenkins environment variables
jenkins email test results
jenkins email build parameters

I have Jenkins job that has execute shell part in which I have some variable BUILD that is dynamically populated.

After build execution, I want to pass this variable to email-ext plugin Default Content to able to show it's value.

I've tried couple of ways without a success:

  1. Passing this ${BUILD} value in Default Content is not recognized (Only Jenkins environment variables are visible in this context)
  2. Defined new Jenkins global environment variable and tried to overwrite its initial value in shell context which apparently is not possible

Any idea on how to do this?


In my case, I'm not the administrator, then I can't install plugins. But can be done with a workaround.

In Content Token Reference help you can found an useful tool.

${PROPFILE,file="FILENAME",property="PROPERTYNAME"}

Expands to the value of a property in a property file. The filename is relative to the build workspace root.

Then save values in a property file inside Build > Execute Shell:

rm -f ${WORKSPACE}/env.properties
touch ${WORKSPACE}/env.properties 
store="/opt/current/store"

echo "store.folder=${store}" >> ${WORKSPACE}/env.properties

echo "${store}"

And read it from Post-build Actions > Editable Email Notification with:

${PROPFILE,file="env.properties",property="store.folder"}

Using variables within the Jenkins email subject lines, I would like to use variables within Jenkins email subject lines. the job, now i'm not sure if you can actually create a variable during the job execution (from a shell script) and use it. email-ext or the normal emailer? Well, email-ext has access to all the Jenkins environment variables for jobs. Below is a list in the Jenkins documentation. Some plugins also add their own variables


You can pass build parameters to email ext plugin by using:

${ENV,var="CAPITALIZED:VAR_NAME"}

In that way i see the variable value in the received mail.

Jenkins users, How to get a parameter into my Email-Ext plugin. Is there a way to show a paramerized string in my email that I send? I have tried but cant make  Andrew Bayer added a comment - 2018-02-12 12:55 You're setting a variable named FOO in the script block, but it's only in that scope. In general, if you need to do this kind of variable-passing, I'd recommend you use Scripted Pipeline, not Declarative.


Simple and easy:

In your "Execute Shell"

echo "test log" > /some/file/path/logFile.txt

Then in your "Editable Email Notification-Default Content"

${FILE,path="/some/file/path/logFile.txt"}

Build and you will receive a email with content "test log"


To see more email tokens, you can click the question mark beside "Content Token Reference" in "Editable Email Notification" section.

[JENKINS-2413] [Email plugin] Read parameters/variables used , http://hudson.gotdns.com/wiki/display/JENKINS/Email-ext+plugin. Cannot read environment variables or project parameters that were set by Guillermo Martinez If you use pipeline to send the email - then I do not see the  Mor L added a comment - 2017-07-05 18:10 - edited scott carlson I fail to see why you have problems with pipeline - since pipeline has env available to you - you don't need a special syntax.


Use EnvInject Plugin to read the variable from a file, after you write that file in the "shell part".


In general, environment variables never go from child process back to parent process, this is basic feature of both Windows and Unix operating system families. Child always gets a copy of parent's environment, and if it modifies it, it modifies it's own copy (which is then copied to any child process if it launches any, etc). But to get changes back, some other method must be used, such as child writing desired changes to a file, which is then parsed by parent, which can then edit it's own environment based on it.

Jenkins, jenkins windows shell-script I'm using the email ext-plugin for Jenkins. I'm using envInject for loading variables from a file. You should be able to pass the current params as an argument to the batch file and then assign You can have this step as the post-build step before you call the email plugin. I have written a simple script via PowerShell to gather some files and zip them into one folder, lets call it Script.ps1. I want to make the script run every time Jenkins does a new build, however I also would like the name of the zip file to be the BUILD_NUMBER. How can I create a variable in PowerShell that is


Passing variable from shell to email-ext in Jenkins - jenkins, You can pass build parameters to email ext plugin by using: ${ENV,var="​CAPITALIZED:VAR_NAME"} In that way i see the variable value in the received mail. My goal is for Jenkins to generate .jar files as artifacts after I kick off a build of Java code. I did try to configure Jenkins with post-build actions to "archive the artifacts." That however causes the builds to fail because there are no artifacts. I am doing a parameterized build. The builds pass, but nothing is generated.


Email-ext, Before using email-ext on a project, you must configure some global settings. The pre-send script is a feature which allows you to write a script that can modify Use the Jelly token with the template parameter equal to your script filename  I have Jenkins job that has execute shell part in which I have some variable BUILD that is dynamically populated. After build execution, I want to pass this variable to email-ext plugin Default Content to able to show it's value. I've tried couple of ways without a success:


How to Configure Email Notification in Jenkins - pradeep sg, How do I set an editable email notification in Jenkins?