Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I format jenkins build server emails so that the content is not all on the same line?

I have used hudson in that past and am very happy with it. It seemed to work well.

I recently installed jenkins and set up the editable email plug in.

Jenkins Version: 1.513 Email-ext plugin version: 2.28

Unfortunately when I try to add other tokens/over ride the default email it just appends all the tokens to the same line.

This is confusing. I have the email set up for html.

Any hints on how to format this nicer?

The default email sent (not the editable one) works ok, but I would like more useful information.

Unfortunately the format of this email makes it close to useless.

here is my editable content:

$BUILD_TAG

$BUILD_ID

$SVN_REVISION

$CHANGES

$CAUSE

$DEFAULT_CONTENT

$WARNINGS_NEW

$WARNINGS_COUNT

Here is the email received:

jenkins-DotNet-43 2013-05-13_16-09-40 7481 [kevin] -help layout Started by an SCM change DotNet - Build # 43 - Successful: Check console output at http://[buildserver]:8080/job/DotNet/43/ to view the results. [kevin] -help layout Started by an SCM change [...truncated 142 lines...] CopyFilesToOutputDirectory: Copying file from "obj\Release\Model.Wpf.dll" to "bin\Release\Model.Wpf.dll". Model.Wpf -> C:\Jenkins.jenkins\jobs\DotNet\workspace\dotnet\Messenger\Model\Model.Generic\bin\Release\Model.Wpf.dll Copying file from "obj\Release\Model.Wpf.pdb" to "bin\Release\Model.Wpf.pdb". Done Building Project "C:\Jenkins.jenkins\jobs\DotNet\workspace\dotnet\Messenger\Model\Model.Ge

EDIT

Note: when I put in "< BR >" entries between items they are separated by linefeeds in the email. Unfortunately though within the tokens themselves (like the change list) the are NO line separators - for example multiple commits are listed all on one line.

The content is there, but it is difficult to decipher. It seems there is a bug in the mail plugin or some other related system.

like image 311
Tim Avatar asked May 13 '13 19:05

Tim


People also ask

Which server details should be configured for the email notification in Jenkins?

Go to the Jenkins home page and click the 'Manage Jenkins' menu option. Then, select the 'Configure System' option. Enter the SMTP server name under 'Email Notification'. Click the 'Advanced' button and then click the checkbox next to the 'Use SMTP Authentication' option.


2 Answers

One may try

mimeType:'HTML/text'

with the emailext plugin and use HTML <br> tag for new lines. Surprisingly mimeType:'text/html' didn't work in my case whereas mimeType:'HTML/text' did.

like image 183
Sid Avatar answered Oct 23 '22 21:10

Sid


You already noticed that you need to actually use HTML line breaks between tokens so they don't show up on the same line, so I'll just answer the part about the multiple change log entries on the same line.

From the Content Token Reference, bold emphasis mine:

${CHANGES, showPaths, showDependencies, format, pathFormat} Displays the changes since the last build.

  • showDependencies - if true, changes to projects this build depends on are shown.

    Defaults to false.

  • showPaths - if true, the paths modified by a commit are shown.

    Defaults to false.

  • format - for each commit listed, a string containing %X, where %X is one of %a for author, %d for date, %m for message, %p for paths, or %r for revision. Not all revision systems support %d and %r. If specified, showPaths is ignored.

    Defaults to "[%a] %m\n".

  • pathFormat - a string containing %p to indicate how to print paths.

    Defaults to "\t%p\n".

The unparameterized ${CHANGES} token is set up for display in a plain text email. You need to configure it so it displays properly in an HTML environment.

Example: <ul>${CHANGES, format="<li>[%a] %m</li>"}</ul>

like image 36
Daniel Beck Avatar answered Oct 23 '22 21:10

Daniel Beck