Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending email in Jenkins with body from content in file

Tags:

jenkins

Ive downloaded plugin for jenkings to sending emails. What I have is 2 files:

ReleaseNotes.txt
config.properties

The first one contains release notes in plain text, the second one contains the same release notes as properties file. I can send them as attachment via this plug in, but I wish to add the content as mail content.

Option 1: Somehow add content of ReleaseNotes.txt to my mail

Option 2: Set new environmental variable from config.properties and add them to mail.

Esther one of the options will satisfy me, can you please help me with one of them? In your answer please not just send me link to plugin but actually help me and explain how to achieve it. I saw some plugins but I struggled using them.

like image 297
Dim Avatar asked Jun 26 '16 14:06

Dim


2 Answers

With the Email Extension Plugin v2.61 you can just do

<pre>
${FILE, path="file_name.txt"}
</pre>

in the Default Content session and keep the format

like image 186
Lewen Zhang Avatar answered Oct 17 '22 09:10

Lewen Zhang


You should be able to combine Environment Script plugin with Email-ext plugin to achieve the desired functionality.

Check the generate environment variable from script option in the build environment section.

Then create the script to read the file content, like this:

echo RELEASE_NOTES=$(cat ReleaseNotes.txt)

In the extended email notification configurations section, fill the default content field with your recently created variable $RELEASE_NOTES

like image 29
Rogério Peixoto Avatar answered Oct 17 '22 08:10

Rogério Peixoto