• Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Blocker Blocker
    • email-ext-plugin
    • None
    • Jenkins ver. 1.642.2, Email Extension Plugin v2.53

      I have read the documentation but cannot understand how to customize the email body. I am an experienced Perl software developer, but I have no experience of jelly or groovy. I understand the principle but the instructions are lacking in detail.

      What I've tried:
      In the "Pre-send Script" field I have put: ${SCRIPT,template="hello.groovy"}
      In the file /var/jenkins_home/email-templates/hello.groovy I have put:
      <%
      println "Hello world!"
      %>

      When I test this in the "Email Template Testing" page, I get the result: Hello world!

      But when I try it in a real job, I get the error below in the console:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Script1.groovy: 1: unexpected token: world @ line 1, column 7.
      Hello world!
      ^
      1 error
      (stack trace snipped)

      Could a minimal "hello world" script be provided which demonstrates how to define an email body?

          [JENKINS-41210] Cannot define custom email body

          Alex Earl added a comment -

          You don't put the \${SCRIPT} token in the pre-send script. The pre-send script is for running operations that would allow you to modify the message before it is sent, or cancel sending the message. You put the content you want in the email in the "Default Content" or in the Content for a specific trigger. There are help buttons next to all the fields that will give you information on how to use them.

          Alex Earl added a comment - You don't put the \${SCRIPT} token in the pre-send script. The pre-send script is for running operations that would allow you to modify the message before it is sent, or cancel sending the message. You put the content you want in the email in the "Default Content" or in the Content for a specific trigger. There are help buttons next to all the fields that will give you information on how to use them.

          Random Je added a comment -

          Right, that makes sense. I guess I misunderstood the form. It now works as expected.

          The "Content Token Reference" is a little hard to find.

          Thanks!

          Random Je added a comment - Right, that makes sense. I guess I misunderstood the form. It now works as expected. The "Content Token Reference" is a little hard to find. Thanks!

          I dare to resolve this issue as the issue reporter is seemingly happily using it already, cf. his comment "It now works as expected."

          Reinhold Füreder added a comment - I dare to resolve this issue as the issue reporter is seemingly happily using it already, cf. his comment "It now works as expected."

            davidvanlaatum David van Laatum
            randomje Random Je
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: