Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-26478

Store Content Token Email Body In A File So It Can Be Reused In Other Jobs

    Details

    • Similar Issues:

      Description

      I've been trying to setup a few jobs with the email-ext plugin to get a more detailed email report for each build. The email-ext plugin is currently configured to have all of the Content Token content in the Default Content field. The content is the same in all of them and I would like to store the template in a file and reference that file in the jobs.

      I havent' been able to determine if this is possible based on the documentation or from related questions on stackoverflow and other sites.

      It seems like the only way to use a file based template is to use the

      {SCRIPT}

      or

      {JELLY_SCRIPT}

      tags pointing to a file in $JENKINS_HOME/email-templates or the Config File Plugin with the "managed:" prefix. When using either of those tags with a simple Content Token formatted template I get multiple parsing errors (unexpected token) trying to evaluate them as either Groovy or Jelly. This same content parses just fine when used in the Default Content field.

      I don't have any need for Jelly or Groovy at this point, I just want to reuse the same Content Token formatted template in multiple jobs.

      Is what I'm trying to do possible? If it is, could the documentation be updated to refelct how to store, format, and refernece that kind of template in a job?

        Attachments

          Activity

          Hide
          slide_o_mix Alex Earl added a comment -

          Looks like only non-private tokens are currently supported this way. The DEFAULT_CONTENT token is a "private" token to email-ext, so it's not exposed to the token-macro interface directly.

          Show
          slide_o_mix Alex Earl added a comment - Looks like only non-private tokens are currently supported this way. The DEFAULT_CONTENT token is a "private" token to email-ext, so it's not exposed to the token-macro interface directly.
          Hide
          slide_o_mix Alex Earl added a comment -

          The other thing you could do is something like this in the content entry field:

          $DEFAULT_CONTENT
          
          ${SCRIPT, template="groovyFileThatDoesAllTheContentTokenStuff.template"}
          
          Show
          slide_o_mix Alex Earl added a comment - The other thing you could do is something like this in the content entry field: $DEFAULT_CONTENT ${SCRIPT, template= "groovyFileThatDoesAllTheContentTokenStuff.template" }
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Alex Earl
          Path:
          src/main/java/hudson/plugins/emailext/AttachmentUtils.java
          src/main/java/hudson/plugins/emailext/plugins/ContentBuilder.java
          src/main/java/hudson/plugins/emailext/plugins/content/AbstractEvalContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/JellyScriptContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/ScriptContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/TemplateContent.java
          src/main/resources/hudson/plugins/emailext/plugins/content/TemplateContent/help.groovy
          src/test/java/hudson/plugins/emailext/plugins/content/JellyScriptContentTest.java
          src/test/java/hudson/plugins/emailext/plugins/content/ScriptContentTest.java
          http://jenkins-ci.org/commit/email-ext-plugin/9b00d7831e6097de30ebbc9366ff4d6d836513f8
          Log:
          Fix JENKINS-26478

          Added new TEMPLATE content token that can be used to pull in email
          content from a file.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: src/main/java/hudson/plugins/emailext/AttachmentUtils.java src/main/java/hudson/plugins/emailext/plugins/ContentBuilder.java src/main/java/hudson/plugins/emailext/plugins/content/AbstractEvalContent.java src/main/java/hudson/plugins/emailext/plugins/content/JellyScriptContent.java src/main/java/hudson/plugins/emailext/plugins/content/ScriptContent.java src/main/java/hudson/plugins/emailext/plugins/content/TemplateContent.java src/main/resources/hudson/plugins/emailext/plugins/content/TemplateContent/help.groovy src/test/java/hudson/plugins/emailext/plugins/content/JellyScriptContentTest.java src/test/java/hudson/plugins/emailext/plugins/content/ScriptContentTest.java http://jenkins-ci.org/commit/email-ext-plugin/9b00d7831e6097de30ebbc9366ff4d6d836513f8 Log: Fix JENKINS-26478 Added new TEMPLATE content token that can be used to pull in email content from a file.
          Hide
          slide_o_mix Alex Earl added a comment -

          Added new TEMPLATE token that will take content from a txt file, or managed file.

          Show
          slide_o_mix Alex Earl added a comment - Added new TEMPLATE token that will take content from a txt file, or managed file.
          Hide
          timmyleahy Timmy Leahy added a comment -

          Awesome! Thanks Alex!

          Show
          timmyleahy Timmy Leahy added a comment - Awesome! Thanks Alex!

            People

            • Assignee:
              slide_o_mix Alex Earl
              Reporter:
              timmyleahy Timmy Leahy
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: