1
votes

I have groovy email template(for Selenium Robot framework test execution) for Jenkins. Jenkins master is controlled by a remote team. So for placing this template in $JENKINS_HOME/email-templates, we need to raise a ticket and wait from 2 to 3 days. Also we expect, there might be changes required in template. So we are planning to put our templates inside our source code repository (GIT). so in the Jenkins test job, we checkout the test script together with email templates. How to instruct Jenkins to look for the template in workspace folder instead of $JENKINS_HOME/email-templates in Jenkins Master

2
I'm working on adding this feature to email-ext. Basically it will allow you to specify a workspace relative path in the content tokens. For example, if you had a template at WORKSPACE/templates/foo.template, you would specify ${SCRIPT, template="templates/foo.template"} to use that template.slide
@slide Thanks a lot. It would be really helpfulJagadish Chandran
@slid, any update on your work of the template path?Heinz
I handed off development of the plugin to someone else because I didn't have time to continue working on it. I know there was some push back on this because of security considerations.slide

2 Answers

1
votes

Sadly it seems you would need to modify the email-ext plugin as the search path is hardcoded into it.

You can see it here, check the occurrence on line 69 in file src/main/java/hudson/plugins/emailext/EmailExtTemplateAction.java

Changing it to another path would be trivial, however adding multiple locations you'd probably have to put some work in.

Edit: I wonder if it would be possible to put the wanted stuff into some txt file as a build step, and then load it into the mail content via some template configuration. If you have access to the job configuration this might be worth checking.

0
votes

You can copy the template into the build workspace (e.g. with SCM step), and then email-ext can reach it:

${SCRIPT, template="${WORKSPACE}/foo.template"}