Job Output as Plain Text in Email Notification

207 views
Skip to first unread message

jcro...@gmail.com

unread,
Apr 17, 2019, 4:49:07 PM4/17/19
to rundeck-discuss
I am totally lost when it comes to formatting / creating custom email templates.

Can anyone provide me a truly step-by-step method of how to get job output to appear in an email notification as plain text? It currently comes across as HTML formatted. The problem I have is that most of the output I require is from the ssh console.

For example, I run this command on my RHEL Satellite server, and the console output appears normally. (This is what I would prefer the email notification to look like)

hammer task list --search running
---|------|-------|------------|----------|-------|--------|-------------|------------
ID | NAME | OWNER | STARTED AT | ENDED AT | STATE | RESULT | TASK ACTION | TASK ERRORS
---|------|-------|------------|----------|-------|--------|-------------|------------


But when I run the same command through Rundeck, the output in my email notification is formatted like this:

---|------|-------|------------|----------|-------|--------|-------------|------------ ID | NAME | OWNER | STARTED AT | ENDED AT | STATE | RESULT | TASK ACTION | TASK ERRORS ---|------|-------|------------|----------|-------|--------|-------------|------------



Any help is appreciated!!


rac...@rundeck.com

unread,
Apr 18, 2019, 1:03:27 PM4/18/19
to rundeck-discuss
Hi,

In your email template you can use:

<pre>
${logoutput.data}
</pre>


And you see the "text formatted" email like this:

Screenshot_20190418_125544.png


Hope it helps!

jcro...@gmail.com

unread,
Apr 19, 2019, 7:27:39 AM4/19/19
to rundeck-discuss
Would you be able to describe how to create / use an email template?

I'm afraid the online documentation isn't very clear on how to do that. Could you show me exactly how you've configured yours? I've edited my rundeck-config.properties to include the following:

rundeck.mail.success.template.file=/root/success-template.html
rundeck.mail.success.template.log.formatted=false

The content of success-template.html is as follows:

<div>Execution ${execution.id} was <b>${execution.status}</b></div>
<ul>
    <li><a href="${execution.href}">Execution result</a></li>
    <li><a href="${job.href}">Job</a></li>
    <li><a href="${execution.projectHref}">Project: ${execution.project}</a></li>
    <li><a href="${rundeck.href}">Rundeck</a></li>
</ul>
<p>
${logoutput.data}
</p>

I'm doing something wrong. I'm just not sure what it is. I'll replace the <p> tags with <pre> once I have things corrected.

rac...@rundeck.com

unread,
Apr 19, 2019, 9:34:10 AM4/19/19
to rundeck-discuss
Hi!

Yes, sure.

In rundeck-config.properties:

# Email notification settings
grails
.mail.host=smtp.yourserver.net
grails
.mail.port=25
grails
.mail.username=yourusername
grails
.mail.password=yourpassword

# apply to any triggers not specified
rundeck
.mail.template.subject=SUBJECT DATA
rundeck
.mail.template.file=/path/to/your/template/template.html
rundeck
.mail.template.log.formatted=false


And my template.html file:

<pre>
${logoutput.data}
</pre>

Tip: Make sure that rundeck user can access to the template file (I can see your  template in /root directory).

Hope it helps!

jcro...@gmail.com

unread,
Apr 19, 2019, 10:54:49 AM4/19/19
to rundeck-discuss
This was incredibly helpful. I didn't have the Email notification settings section populated at all. So after I put those in there and added the <pre> tags as you recommended everything works great! Thanks for this. I really do appreciate the hand holding here!! :)
Reply all
Reply to author
Forward
0 new messages