emailext(
from: 'Jenkins',
replyTo: 'none',
recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']],
subject: '[Jenkins] ${PROJECT_NAME} - build #${BUILD_NUMBER} - ${BUILD_STATUS}',
mimeType: 'text/html',
to: '${GERRIT_CHANGE_OWNER_EMAIL}',
body: '${SCRIPT, template="managed:groovy-html.template"}'
)
in the to: section i want to use the env variable "GERRIT_CHANGE_OWNER_EMAIL" but it not passing the value ( i tried also with env.GERRIT_CHANGE_OWNER_EMAIL and also /${env.GERRIT_CHANGE_OWNER_EMAIL}
what is your suggestion to handle these cases?
thanks in advance!
Amit
Hi Amit,
(a) in your code/screenshot example the problem:
to: '${GERRIT_CHANGE_OWNER_EMAIL}',
[…]
in the to: section i want to use the env variable "GERRIT_CHANGE_OWNER_EMAIL" but it not passing the value ( i tried also with env.GERRIT_CHANGE_OWNER_EMAIL and also /${env.GERRIT_CHANGE_OWNER_EMAIL}
… the problem is a Groovy one:
(b) And in the groovy html template code there are IMHO only certain variables explicitly injected:
HTH Reinhold
Hi Amit,
(a) in your code/screenshot example the problem:
to: '${GERRIT_CHANGE_OWNER_EMAIL}',
[…]
in the to: section i want to use the env variable "GERRIT_CHANGE_OWNER_EMAIL" but it not passing the value ( i tried also with env.GERRIT_CHANGE_OWNER_EMAIL and also /${env.GERRIT_CHANGE_OWNER_EMAIL}… the problem is a Groovy one:
- Please replace the single quotes with double quotes to allow string interpolation
this one worked - tnx for that!
(b) And in the groovy html template code there are IMHO only certain variables explicitly injected:
- Based upon http://stackoverflow.com/a/9983405 and https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/java/hudson/plugins/emailext/plugins/content/ScriptContent.java please note the “binding.put(...)” calls, e.g.:
- build ... org.jenkinsci.plugins.workflow.job.WorkflowRun for Pipeline jobs
- project == build.getParent() ... org.jenkinsci.plugins.workflow.job.WorkflowJob - the job/project instance for this build
- it ... ScriptContentBuildWrapper(build) (internal ExtEmail class)
- rootUrl … Jenkins URL as set in your Jenkins configuration
regard this part - i know these params but i'm sure that we can manipulate the template in some way to have values that no on build... for example , i have file in my workspace that contains all the values that i want to use in the mail, will it be available in the post in the template? can i import this file context into some map and use it in my email template?
HTH Reinhold