Search code examples
jenkins

Sending email in Jenkins with body from content in file


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.


Solution

  • 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