Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to render standard velocity template in JIRA Scriptng Suite

marchyn January 8, 2014

Hi,

I need to send email based on standard velocity template from Jira Scripting Suite post action during issue creation. I need to implement condition checker. I think I have everything necessary but getting very strange exception when generating HTML output.

Using Jira 6.1.5 with the latest Jira Scripting Suite.

I will appreciate any help.

JSS Code:

from com.atlassian.jira.component import ComponentAccessor
from java.util import HashMap
from java.lang import String
from java.lang import Object
from java.lang import System
from com.atlassian.jira.config.properties import APKeys

ap = ComponentAccessor.getApplicationProperties();
baseUrl = ap.getString(APKeys.JIRA_BASEURL);
webworkEncoding = ap.getString(APKeys.JIRA_WEBWORK_ENCODING);

vm = ComponentAccessor.getVelocityManager()
vp = ComponentAccessor.getVelocityParamFactory()

context = vp.getDefaultVelocityParams()
context.put("issueObject", issue)
context.put("baseurl", baseUrl)

renderedText = vm.getEncodedBody("C:/atlassian-jira/WEB-INF/classes/templates/email/html/", "issuecreated.vm", baseUrl, webworkEncoding, context);

log.info("-----")
log.info(renderedText)
log.info("-----")

Error:

/secure/QuickCreateIssue.jspa [jira.plugin.workflow.JythonPostFunction] An error occurred whilst rendering this message.  Please contact the administrators, and inform them of this bug.

Details:
-------
java.lang.IllegalArgumentException: name
	at sun.misc.URLClassPath$Loader.findResource(Unknown Source)
	at sun.misc.URLClassPath.findResource(Unknown Source)

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Adrian Moerchen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2014

Try

renderedText = vm.getEncodedBody("templates/email/html/", "issuecreated.vm", baseUrl, webworkEncoding, context);

0 votes
Marijo Mateljan February 3, 2014

I think it is not very wise to use to absolute path to the resource!

TAGS
AUG Leaders

Atlassian Community Events