I'm using the Email-Ext plugin to send a results email at the end of my build in the post build stage of a declarative pipeline. In the body of the email I'm trying to insert some environment variables and some user defined environment variables.
The built in variables show up fine, however any user defined variables I define are just empty in the body of the email or don't work in the attachmentPattern field either:
My environment variables:
pipeline {
agent any
environment {
buildFolder = "build_${BUILD_NUMBER}"
robotFolder = "build_${BUILD_NUMBER}/robotDemo"
serverName = "abc123"
robotResults = "${buildFolder}/*.txt"
}
The email-ext format I am using in my post{} build:
emailext attachLog: true, attachmentsPattern: 'build_${env.BUILD_NUMBER}/Robot_Results.txt', body: '<b>Job Name:</b> ${ENV, var="JOB_NAME"}<br><b>Build Number:</b> ${ENV, var="BUILD_NUMBER"}<br><br><b>Build URL:</b><br>${ENV, var="BUILD_URL"}<br><br><b>Log Files:<br><br><br><pre>${BUILD_LOG_EXCERPT, start="^====", end="^report.html"}</pre><pre>${ENV, var="serverName"}</pre>', mimeType: 'text/html', subject: 'ABS Results', to: 'richard.scott@sap.com'
For example: ${ENV, var="JOB_NAME"}, shows up fine. However ${ENV, var="serverName"} doesn't show at all.
I've tried variations such as...
${serverName}
${env.serverName}
...but they don't work either.
Any ideas how to use user defined environment variables like 'serverName' above in the email-ext plug-in?
Thanks & best regards, Richard.