Re: emailext using groovy-html.template with environment variables issue

2019-08-11 Thread amit r

*Hi Reinhold, *
*thank you for your help!*
*pls see inline*

בתאריך יום חמישי, 8 באוגוסט 2019 בשעה 07:45:34 UTC+3, מאת Reinhold Füreder:

> 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? 
>
 as i know , we have already the option to run build.getEnvVars() but only 
for specific values that inside build context - not the env values that i'm 
looking for...
do you see other option for it?

 

> HTH Reinhold
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/dfe5f429-b31f-4dac-af88-65c98f8806b6%40googlegroups.com.


RE: emailext using groovy-html.template with environment variables issue

2019-08-07 Thread Reinhold Füreder
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


(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

HTH Reinhold

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/AM0PR01MB6147232554C60333C07B17DDF7D70%40AM0PR01MB6147.eurprd01.prod.exchangelabs.com.


emailext using groovy-html.template with environment variables issue

2019-08-07 Thread amit r
Hi All, 
i'm using jenkinsFile and for lone time using also the emailext plugin with 
some default params that were ok for now..

now i reached to some issues that i want to use in my groovy html template 
variables that were used in my jenkinsFile  - for example env variables.

its not clear to me how can i access them within the template..
the only thing i found online is the :
build.getEnvVars() but this one also give very limited info and not on my 
env variables that i used in my build..

in addition , see some examples online that use project.name or 
build.result ... how can i know which options i have to use in this 
template? 


on top of it:
in the jenkinsFile it self we have this section:

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

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/a788acb9-f1c2-4cc1-98b9-6437195c315d%40googlegroups.com.