5

I need to modify the extended email part for email notification in jenkins. This is what I have right now:

enter image description here

This just shows first line of commit message in the email. I would like to grab multiple lines from commit message.

I found this: https://issues.jenkins-ci.org/browse/JENKINS-12289 So I tried following, did not work.

enter image description here Please somebody suggest how to fix it.

Thanks tons!

sharp
  • 633
  • 3
  • 12
  • 21
  • "did not work" how? Can you be more specific? – Jonathan Hall Aug 11 '15 at 21:54
  • Did not work means: It is unable to display multiple lines of git commit. It just takes first line of commit. – sharp Aug 16 '15 at 05:00
  • If somebody can give me jelly or groovy script for getting multiple line commit also should be fine. – sharp Aug 16 '15 at 05:01
  • Looking at the valid values there does not seem to be any way to get the entire %m Commit Message into the email. It just cuts it off. This would be nice to have the plugin show the entire message as then the email has no real value to it except to say something deployed. – bytor99999 Feb 24 '17 at 17:23

1 Answers1

0

The comments are being cut off to 71 or 72 characters because behind the scenes email ext uses the title property instead of the comment property.

Save this in Jenkins > email-templates as test.template. Note the use of cs.comment instead of cs.title

<!-- CHANGE SET -->
  <%
  def changeSets = build.changeSets
  if(changeSets != null) {
    def hadChanges = false %>
  <table class="section">
    <tr class="tr-title">
      <td class="td-title" colspan="2">CHANGES</td>
    </tr>
    <% changeSets.each() { 
      cs_list -> cs_list.each() { 
        cs -> hadChanges = true %>
    <tr>
      <td>
        Revision
        <%= cs.metaClass.hasProperty('commitId') ? cs.commitId : cs.metaClass.hasProperty('revision') ? cs.revision : cs.metaClass.hasProperty('changeNumber') ? cs.changeNumber : "" %>
        by <B><%= cs.author %></B>
      </td>
      <td>${org.apache.commons.lang.StringEscapeUtils.escapeHtml(cs.comment)}</td>
    </tr>
        <% cs.affectedFiles.each() {
          p -> %>
    <tr>
      <td class="filesChanged">${p.editType.name}</td>
      <td>${p.path}</td>
    </tr>
        <% }
      }
    }
    if ( !hadChanges ) { %>
    <tr>
      <td colspan="2">No Changes</td>
    </tr>
    <% } %>
  </table>
  <br/>
  <% } %>

Then in your Post-build Editable Email "default content" put the following line:

${SCRIPT, template="test.template"}

Eric Nelson
  • 337
  • 4
  • 15