Are jelly templates supported in email-ext with pipeline

2,190 views
Skip to first unread message

Rinaldo DiGiorgio

unread,
Feb 9, 2016, 12:32:19 PM2/9/16
to Jenkins Users
I am able to use email-ext with pipeline to send emails.  I am trying to use jelly templates. I do not see an option for the template processor in the following. I tried adding SCRIPT to the body.


    emailext attachLog: true, body: ' ${SCRIPT, template="html/test.groovy"}', subject: 'Test of email', to: 'somea...@somedomain.com'






Slide

unread,
Apr 16, 2016, 2:16:35 PM4/16/16
to Jenkins Users
No, this is not currently supported. Token macro, which is the basis for the SCRIPT token doesn't currently support the type of object that pipeline uses.

On Tue, Feb 9, 2016 at 10:32 AM Rinaldo DiGiorgio <digital...@gmail.com> wrote:
I am able to use email-ext with pipeline to send emails.  I am trying to use jelly templates. I do not see an option for the template processor in the following. I tried adding SCRIPT to the body.


    emailext attachLog: true, body: ' ${SCRIPT, template="html/test.groovy"}', subject: 'Test of email', to: 'somea...@somedomain.com'






--
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/f7ed76fc-7c0d-4b5d-b582-5e39d468809d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Bidewell

unread,
Apr 21, 2016, 9:30:32 AM4/21/16
to Jenkins Users
Is support planed for a future release?

Slide

unread,
Apr 21, 2016, 10:21:52 AM4/21/16
to Jenkins Users

The biggest hurdle at this point is that email-ext uses token macro for token replacement and token macro is built around AbstractBuild, which pipeline does not use. I am looking into adding the capability to token macro, and thus email-ext. It's something I am actively working on.


András Gaál

unread,
Oct 13, 2016, 11:08:52 AM10/13/16
to Jenkins Users
Hi, any updates on this?

Regards,
Andrew

dor...@tikalk.com

unread,
May 23, 2017, 8:32:15 AM5/23/17
to Jenkins Users
Any update about that?

I found it really missing..... can not use templates / can not use other token macros such CHANGES...
 
I think that the whole JenkinsFile concept is great but still not mature for real use...

Slide

unread,
May 23, 2017, 9:11:12 AM5/23/17
to Jenkins Users
Many macros should work fine by putting them in the body or subject fields of the pipeline. SCRIPT specifically uses some things from AbstractBuild, which a pipeline job is not, so that is why SCRIPT can't be used. It would need to be updated to support pipeline jobs as well. 

Doron Shai

unread,
May 23, 2017, 9:12:56 AM5/23/17
to jenkins...@googlegroups.com
Do you know how i can use the CHANGES script token ? It does not see to be possible according to what I tried....

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/turlQIsPgCc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPiUgVd12VDOobAnY6HmJybEWkRps8meY1ODndWxU3nbPeuj_Q%40mail.gmail.com.

Slide

unread,
May 23, 2017, 9:56:20 AM5/23/17
to jenkins...@googlegroups.com
What did you try, and what was the result?

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/turlQIsPgCc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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.

jer...@bodycad.com

unread,
May 23, 2017, 1:18:40 PM5/23/17
to Jenkins Users
Into pipeline they are working to certain extent, but you have to take special care when declaring the usage of the body (it does not support windows \ into the path, convert to unix path type):

emailext body: '${JELLY_SCRIPT,template="/path/to/templatefile.template"}', subject: 'subject', to: 'myt...@test.com', replyTo: 'jen...@test.com', mimeType: 'text/html';

I for one also made a replacement function to replace the variables into the template file and write it again with the replacement.
  1. read the template with special string to be replaced
  2. replace some variables into the string
  3. write the template into the tempo folder of the master (since a few release it no more check on the slave with absolute path).
  4. Send the tempo filled copy.
It's the best way I found to do this with a few function I load every project. I give it a dictionary to replace all values into the template. I also have something that convert windows path to Unix path style and generate the whole body entry with a simple path. So I don't bother with what is available or not into the Jelly context/parsing anymore. It give me more freedom and I known what to expect every time, I also have some style replacement based on the project (devel, official, etc) that I can now inject based on the project/branch/result...

Another fun part, is to combine multiple template part together based on the build results ;-)

Seb M

unread,
Jun 18, 2017, 1:44:00 AM6/18/17
to Jenkins Users
To pick this up again, i also tried to get this to work and ran into some issues:
 emailext (
      subject: "subject",
      body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
 <div style="padding-left: 30px; padding-bottom: 15px;">
   ${CHANGES, showPaths=true}

  </div>
    <p>Check console output at "<a href="${env.BUILD_URL}">${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>""",
      recipientProviders: [[$class: 'CulpritsRecipientProvider']]
    )

would just give me a "Unexpected Token" Groovy Error. Using:
 emailext (
      subject: "subject",
      body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
 <div style="padding-left: 30px; padding-bottom: 15px;">
   ${CHANGES(showPaths: true)}

  </div>
    <p>Check console output at "<a href="${env.BUILD_URL}">${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>""",
      recipientProviders: [[$class: 'CulpritsRecipientProvider']]
    )

i get:
java.lang.NoSuchMethodError: No such DSL method 'CHANGES' found among steps 

So this does not really seam to work? Or is there some error in my syntax?
Regards,
Seb

Daniel Beck

unread,
Jun 19, 2017, 7:15:40 AM6/19/17
to jenkins...@googlegroups.com

> On 18. Jun 2017, at 07:43, Seb M <sebastian...@gmail.com> wrote:
>
> So this does not really seam to work? Or is there some error in my syntax?

Tri triple-single-quoted strings or escaping the $ -- right now, it's looking for a DSL variable "CHANGES" as it evaluates the ${CHANGES, …} in the DSL.

Reply all
Reply to author
Forward
0 new messages