In my pipeline script, I added a few environment variables but wasn't able to access it in the email-ext plugin
env.MYVAR = 'HELLO'
emailext body: '${ENV,var="MYVAR"}', subject: 'subject', to: 'hello@world.com'
Since I am reading the email body from a file, I've also tried replacing string but got java.lang.NullPointerException at org.codehaus.groovy.runtime.StringGroovyMethods.replaceAll
def myvariable = 'HELLO WORLD'
def content = readFile 'template.html'
content = content.replaceAll('MYVAR',myvariable)
...
Any idea? Thanks!