Testing the latest version of the pipeline plugins and it appears that it's no longer possible to set empty environment variables. The following works in some current declarative scripts I have still using v1.0.2:
pipeline{
environment{
EMAIL_RECIPIENTS = 'me@me.com'
EMAIL_RECIPIENTS_SUCCESS = ''
}
(some stages and steps)
post {
success {
echo 'Send Success message...'
buildEmailer (currentBuild.result, EMAIL_RECIPIENTS, EMAIL_RECIPIENTS_SUCCESS)
}
failure {
echo 'Send Failed message...'
buildEmailer (currentBuild.result, EMAIL_RECIPIENTS, EMAIL_RECIPIENTS_SUCCESS)
}
}
}
I have emailing logic in shared library (buildEmailer) and do some processing if the incoming variable is blank. The above causes no trouble in plugin version 1.0.2, but in 1.1.2, I get:
However, the script is OK if I move things around and set the variables inside a script {} section inside a stage{}. The reason this particular value is set but blank, is that I let this value be optional and let developers update the desired property to what they want in the build job. I could process some default value in the environment section, but since the scripts works with variables in a script section, and it was working in 1.0.2, it seems like this could be a bug with the environment section.