(Groovy) How to get JIRA base URL into a custom email?

Sameera Shaakunthala [inactive]
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.
September 18, 2012

I'm writing a custom email template for a workflow post function. The requirement is to send an email having some custom content (which is different from the JIRA default email template) once a particular workflow transition has been executed.

In this email I need to include the URL for the issue which is being transitioned. As per the following resolved question, I tried to include the base URL but it did not work.

https://answers.atlassian.com/questions/83904/solved-get-baseurl-field

<%
def baseurl = ComponentAccessor.getApplicationProperties().getString("jira.baseurl")
%>
Click here: $baseurl/browse/$issue

Can someone please shed some light on this?

Many thanks!

--

Shaakunthala

1 answer

1 accepted

2 votes
Answer accepted
Jobin Kuruvilla [Adaptavist]
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.
September 18, 2012

in JIRA4, try this:

ComponentManager.getInstance().getApplicationProperties().getString("jira.baseurl")

Sameera Shaakunthala [inactive]
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.
September 18, 2012

Hi Jobin,

It also didn't work. In the meantime I checked JIRA email template VMs to see how it has been referred. It's just $baseurl in VMs, but does not work in Groovy.

Thanks!

Jobin Kuruvilla [Adaptavist]
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.
September 18, 2012

bit strange. Any error?

Sameera Shaakunthala [inactive]
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.
September 19, 2012

Following is the error,

2012-09-20 06:02:53,561 TP-Processor6 ERROR shaakunthala 362x332x1 1mokv3q 172.25.94.211 /secure/WorkflowUIDispatcher.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function
groovy.lang.MissingPropertyException: No such property: ComponentManager for class: groovy.tmp.templates.GStringTemplateScript1

Stacktrace attached. (groovy_error.txt)

Sameera Shaakunthala [inactive]
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.
September 19, 2012

Following is the error.

2012-09-20 06:02:53,561 TP-Processor6 ERROR shaakunthala 362x332x1 1mokv3q 172.25.94.211 /secure/WorkflowUIDispatcher.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function
groovy.lang.MissingPropertyException: No such property: ComponentManager for class: groovy.tmp.templates.GStringTemplateScript1

Attaching the stacktrace....

Jobin Kuruvilla [Adaptavist]
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.
September 19, 2012

Looks like you don't have import for ComponentManager?

Sameera Shaakunthala [inactive]
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.
September 19, 2012

Small correction: In workflow post function what I tried is to assign it to a variable, $baseurl = ....... (not to return)

Sameera Shaakunthala [inactive]
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.
September 19, 2012

I haven't done it earlier. But now when I tried with the following code, it still did not work.

import com.atlassian.jira.ComponentManager
return ComponentManager.getInstance().getApplicationProperties().getString("jira.baseurl")

Another thing I noticed is, it works in the Script Runner (/secure/admin/groovy/GroovyRunner.jspa).

Sameera Shaakunthala [inactive]
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.
September 24, 2012

Thanks Jobin! It worked. I think I made a mistake during my previous testing. :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events