Jenkins setup:
I would like to check if there’s any way we can send Jelly email templates dynamically from a custom location instead of saving them under the jenkins_home/email-templates directory. I have attached my test Groovy file, and please use the default jelly file from the email extension plugin document.
I tried loading a file and using that variable; however, it’s actually not displaying the details from the jelly file; instead, it’s just showing the static HTML content.
I thought for a split second I had a solution, but alas, I have the same issue, this would only work for static content.
However, here is what I wrote before realizing it could not work this way:
You could try to use a custom location for your Jelly scripts by loading the file content into a variable and then using that variable in the email step.
Here’s how I see it:
First, you would need to read the Jelly script file from your custom location and store its content in a variable. You could use the ‘readFile’ step to do this: def jellyScript = readFile 'path/to/your/jelly/script.jelly'
Then, you could use the emailext step to send the email. In the body parameter, you could use the ${SCRIPT, template="<your_script>"} token to include the content of the Jelly script.
Here’s an example from the top of my head: