Now that I look at this again after looking at the source code. I don’t think there is a good way to get at the environment variables from the template. If you are using pipeline, then AbstractBuild can’t be used at all since pipeline doesn’t inherit from AbstractBuild. This would require an update to the email-ext plugin to work I think.
The only thing I can think of would be to call Run<?,?>.getEnvironment(TaskListener listener) which you should be able to call on the build object that is part of the Jelly script mapping. I am very rusty with Jelly, so I can’t help on how you might do that as it doesn’t look like a TaskListener is set as part of the binding for the Jelly script.
Can you describe your use case a little, perhaps there is another way to accomplish what you want to do.
I’m conducting end-to-end tests and want to send email notification for the passed and failed tests count. The email should also include the test results, the number of servers alive before and after testing, and some environment variables in the template. Unfortunately, Gmail isn’t accepting CSS in my Groovy template then i choose jelly template.
How is gmail not accepting your CSS? The Groovy template output and Jelly output should produce the same thing (e.g. an html file), so switching from Groovy to Jelly probably won’t change the outcome at all.
In groovy you can use them directly and they should resolve. Groovy scripts/templates have a missingMethod lookup that occurs when Groovy can’t find something in the binding. You could also use ENV(var="FOO") as token macros are supported that way as well.
Exception raised during template rendering: Cannot invoke method getEnvironment() on null object
java.lang.NullPointerException: Cannot invoke method getEnvironment() on null object
The use case I have is a new ‘batch’ of functionality is created and an email is sent to a developer group informing them of the new version, the version name is built on the fly in the job. The job does not archive anything.
That means that that action is not found in the job. You may want to try dumping all the actions for your job with it.getAllActions() which you can see the javadoc for here: Actionable (Jenkins core 2.425 API)