Passing the vaiable to Email Extension plugin

14 views
Skip to first unread message

kalkin powale

unread,
Mar 28, 2019, 10:39:37 AM3/28/19
to Jenkins Users
Hi All,

I wish to send some parameter/ variable from the current build job to the Email template to send it in an email.

I have saved my email template as Manage_Jenkins>> Managed_Files >> custom_groovy_Email.groovy

in email template, I am trying to use it as follows
   <td>Duration:</td>
      <td>${build.durationString}</td>
    </tr>
    <tr>
      <td>Cause:</td>
      <td><% build.causes.each() { cause -> %> ${cause.shortDescription} <%  } %></td>
    </tr>
<tr>
      <td>Tool version:</td>
  //<td>${ENV(var="MYTOOL_VERSION")}</td>
          //<td>${ENV(var:"MYTOOL_VERSION")}</td>
  <td>${build.buildVariables.MYTOOL_VERSION}</td>
    </tr>
  </table>
  <br/>

And In the groovy file in job configuration, I have tried setting it like this

import hudson.EnvVars
import hudson.model.Environment
import hudson.model.*

node{
       stage(tool){
               //def MYTOOL_VERSION = '1.33'
                //evn.MYTOOL_VERSION = '1.33'
               def MYTOOL_VERSION = build.getEnvVars()["${MYTOOL_VERSION}"]

       }
}

But it does not seem to be working. 

Can anybody help me in this regards, Thank you.

Slide

unread,
Mar 28, 2019, 1:45:18 PM3/28/19
to Jenkins User Mailing List
It looks like you might be mixing up some usages..if the variable is an environment variable (and that is the only type that will work in a template), you'd want to do something like this:

<td><% ENV(var:"MYTOOL_VERSION") %></td>

This may only work with the most recent email-ext version.

--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/dba3d9d3-2bfb-4343-96db-4b68156b9391%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Reply all
Reply to author
Forward
0 new messages