Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted from v. 18

Groovy Template is a templating engine for JavaScript. It lets you insert dynamic content into any text through the use of templates. A template contains variables and/or expressions, which get replaced with values when a template is rendered. This is very similar to JSP markup. 

...

Code Block
languagegroovy
linenumberstrue
<%= issue.getKey() %>

For single-statement expressions, you can also use the following shortcut:

Code Block
linenumberstrue
${issue.getKey()}


To simply execute a Groovy code and not output the result, write your Groovy code as <% some Groovy code %>. For example:

...

$currentUser returns an ApplicationUser

$currentUser.name returns the username of the current user

To call a method on the variable, use ${variable.method()}:

${currentUser.getName()} also returns the username of the current user

...

Code Block
languagegroovy
linenumberstrue
Issue key: $issue.key${issue.get("issuekey")}

Comment an issue based on the priority of the issue:

...

To send an Email to the Voters and Watchers of the issue when the issue is resolved, write this as the Subject of the Email (note that we mixed <%= %> and ${} expressions only to show how both are valid):

Code Block
languagegroovy
linenumberstrue
Hi All,
<% if (issue.assignee)
{%>
The issue <%= issue.key%> has been resolved by <%=issue.assignee.displayName%>
<%}
else
{%>
The issue $issue${issue.key} has been resolved
<%}%>
Regards,
<%=issue.get("project")?.getLead()?.getDisplayName()%>

...