'Mailing a given string using jenkins code

I'm trying to send an email with body text given in a string variable, and fail. The line of code I use is:

mailtxt = 'ABCD'
emailext attachLog: false, subject:'$DEFAULT_SUBJECT' , to:'[email protected]' , replyTo:'$DEFAULT_REPLYTO', body: '''$mailtxt<div>'''

I have tried several combinations of code fences and $, but never get the string value. Any suggestions? Thanks!



Solution 1:[1]

The string variable can be addressed by "${string}". I suggest for you to read the official Groovy language documentation.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1