How to set URL to an issue on a email template

I want to include the URL that would address to an issue, on a email template. Does anybody know which property to use? Or way to do it?

I thought this would be a simple and basic task, but I've even found any way to do it.

I'm using Script Runner as a way to test a solution before implementing the final template.

TIA,

Charly

3 answers

1 accepted

JIRA's own HTML templates contain URL to the issue itself. You can see the templates on atlassian-jira\WEB-INF\classes\templates\email\html

If you want to test it with ScritRunner you can read the base URL and suffix it with /browse/<issue ID>

I'm not sure how you are testing with script runner, but the "send custom email" post-function uses GString templates, whereas jira uses velocity. You can't mix and match. In script runner you can use ${baseUrl}. Unfort the capitalisation differs from the velocity version.

Thanks Kerem.

I've tried with:

&lt;a href="${baseurl}/browse/${issue.getKey()}"&gt;#text("template.view.online")&lt;/a&gt;

But I got an error resolving ${baseurl} and ${issue.getKey()}. I fixed it replacing temporally ${baseurl} with a hardcoded url (while I see how to fix it) and ${issue.getKey()} with ${issue.key}.

This situation made me think I'm misunderstanding something about that model of objects to use.

Thanks Jamie, I've tried with the post-function as you told me, it works me with:

&lt;a href="$baseUrl/browse/${issue.key}"&gt;$issue&lt;/a&gt;

I couldn't find the right resource to know the correct syntax / property names.

<a href="$baseUrl/browse/${issue.key}">$issue</a> only gives us a hyperlink in our custom emails to $baseUrl/browse. It doesn't append the issue key to the hyperlink

Try using the "out << " syntax as shown in https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Sendacustomemail

The workflow engine might be mangling it.

Does the $issue bit show the key? If it does just use that in both places.

<a href="$baseUrl/browse/<% out << issue.key %>">$issue</a>

This corrected the issue.


This should work:

&lt;a href="$baseUrl/browse/$issue"&gt;$issue&lt;/a&gt;

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

106 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you