Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Email templates are velocity macro files. When email templates are used to render email body, the following Velocity context attributes are available.

 

Name
Type
Description
attachmentsManagercom.atlassian.jira.mail.util.MailAttachmentsManagerManager component
baseurlStringBase url of the JIRA instance, set under General Configuration
buildutilscom.atlassian.jira.util.BuildUtils 
customfieldManagercom.atlassian.jira.issue.CustomFieldManagerSupport for adding custom fields to outgoing emails
dateformattercom.atlassian.jira.web.util.OutlookDateDate format support
issuecom.atlassian.jira.mail.TemplateIssueIssue extended with support for processing in velocity templates
i18ncom.atlassian.jira.util.I18nHelperI18n support
jirakeyutilscom.atlassian.jira.util.JiraKeyUtils 
jirautilscom.atlassian.jira.util.JiraUtils 
remoteUsercom.atlassian.crowd.embedded.api.UserCurrent user running the action or null
rendererManagercom.atlassian.jira.issue.RendererManager 
stringUtilsorg.apache.commons.lang.StringUtilsString helper methods
textutilscom.opensymphony.util.TextUtilsJIRA's text util methods
userutilscom.atlassian.core.user.UserUtils 
velocityhelpercom.atlassian.velocity.VelocityHelper 
jetiFieldRenderer Support for field rendering in templates. See details below.
jetiFieldFormatter Support for date/time formatting in templates. See details below
numbercom.atlassian.jira.util.velocity.NumbertoolSupport for Number formatting in templates. See API documentation
currentUserInfo 

$!currentUserInfo.user: current user object
$!currentUserInfo.roles: current user's project roles
$!currentUserInfo.groups: current user's groups.

jetiFieldRenderer

Code Block
languagejava
titleFieldRenderer Interface
public interface FieldRenderer {
  String renderCustomField(Issue issue, String fieldKey);//
  String renderVersions(Collection<Version> versions);//
  String renderComponents(Collection<ProjectComponent> components);//
  String renderLabels(Collection<Label> labels);//
  String renderSecurityLevel(GenericValue securityLevel);//
  String renderIssueConstant(IssueConstant issueConstant);//
  String renderUser(User user);//
  String renderDateTime(Timestamp ts);//
  String renderEstimate(TemplateIssue ti, I18nHelper i18n);
  String renderRemainingEstimate(TemplateIssue ti, I18nHelper i18n);
  String renderWorklog(TemplateIssue ti, I18nHelper i18n);
  Object renderCustomFieldAsObject(Issue issue, String fieldKey);
  I18nHelper getI18nBean(String locale); //Returns a I18nBean for the given locale, locale string follows java syntax
}
MethodDescriptionUsage
String renderCustomField(Issue issue, String fieldKey);
Renders a custom field value as a string value$!jetiFieldRenderer.renderCustomField($!issue, "customfield_10011")
Object renderCustomFieldAsObject(Issue issue, String fieldKey);

Returns the value of the custom field as Raw value.

The Raw or Object value allows for further processing or access to methods, and attribues

$!jetiFieldRenderer.renderCustomFieldAsObject($!issue, "customfield_10011")

E.g. render the Display name attribute of a user selected in a user picker field

$!jetiFieldRenderer.renderCustomFieldAsObject($!issue, "customfield_10011").getDisplayName()

String renderVersions(Collection<Version> versions);
Renders the given versions as a comma-separated list of version names.E.g. $!jetiFieldRenderer.renderVersions($!issue.getFixVersions())
String renderComponents(Collection<ProjectComponent> components);
Renders the given components as a comma-separated list of component names.E.g. $!jetiFieldRenderer.renderComponents($!issue.getComponents())
String renderLabels(Collection<Label> labels);
Renders the given labels as a comma-separated list of label names.E.g. $!jetiFieldRenderer.renderLabels($!issue.getLabels())
String renderSecurityLevel(GenericValue securityLevel);
Renders the name of the given Security Level object $!jetiFieldRenderer.renderSecurityLevel($!issue.getSecurityLevel())
String renderIssueConstant(IssueConstant issueConstant);
Renders the name of an Issue type, Resolution, Priority or Status$!jetiFieldRenderer.renderIssueConstant($!issue.getPriority())
String renderUser(User user);
Renders the DisplayName attribute of a User or Application User object safely, if null, returns empty string$!jetiFieldRenderer.renderUser($!issue.getAssignee())
String renderDateTime(Timestamp ts);
Renders a Timestamp object using JIRA's default date format, DateTimeFormat.format()

E.g.

  • $!jetiFieldRenderer.renderDateTime($!issue.getCreated())
  • render the value of a date or date time picker field: $!jetiFieldRenderer.renderDateTime($!jetiFieldRenderer.renderCustomFieldAsObject($!issue, "customfield_10011"))
String renderEstimate(TemplateIssue ti, I18nHelper i18n);
Renders the issue's Original estimate in nicely readable format, like 3d 4h 5m$!jetiFieldRenderer.renderEstimate($!issue, $i18n)
String renderRemainingEstimate(TemplateIssue ti, I18nHelper i18n);
Renders the issue's Remaining estimate in nicely readable format, like 3d 4h 5m$!jetiFieldRenderer.renderOriginalEstimate($!issue, $i18n)
String renderWorklog(TemplateIssue ti, I18nHelper i18n);
Renders the issue's Logged Work Time in nicely readable format, like 3d 4h 5m$!jetiFieldRenderer.renderWorklog($!issue, $i18n)
I18nHelper getI18nBean(String locale);

Returns a I18nBean for the given locale, locale string follows java syntax

E.g. get the language resources for French: $!jetiFieldRenderer.getI18nBean("fr")

 

jetiFieldFormatter

Code Block
languagejava
titleFieldFormatters Interface
public interface FieldFormatters {
 
//JIRA Date Formatting Options
  /**
  * @returns An object of https://docs.atlassian.com/software/jira/docs/api/latest/com/atlassian/jira/datetime/DateTimeFormatter.html
  */
  DateTimeFormatter getJiraDateTimeFormatter();
 
  /**
  * @returns An object of https://docs.atlassian.com/software/jira/docs/api/latest/com/atlassian/jira/datetime/DateTimeFormatter.html
  */
  DateTimeFormatter getJiraDateTimeFormatter(String styleName);
 
  /**
	Formats a Date object using the given formatter.
    @returns formatted date string or empty string if format is not valid, never returns null
  */
  String formatSafely(DateTimeFormatter dateFormat, Date value);
 
  /**
	Formats a object using the given formatter. If the value object is not a Date, it returns empty string.

    @returns formatted date string or empty string if format is not valid, never returns null
  */
  String formatSafely(DateTimeFormatter dateFormat, Object value);
 
//Java Date Formatting Options
  DateFormat getJavaDateFormat();
  DateFormat getJavaDateFormat(int style);
  DateFormat getJavaDateFormat(int style, String locale);
  DateFormat getJavaDateTimeFormat();
  DateFormat getJavaDateTimeFormat(int dateStyle, int timeStyle);
  DateFormat getJavaDateTimeFormat(int dateStyle, int timeStyle, String locale);  
  DateFormat getJavaDateTimeFormat(String pattern);
 
  /**
	Formats a object using the given DateFormat. If the value object is not a Date, it returns empty string.

    @returns formatted date string or empty string if format is not valid, never returns null
  */
  String formatSafely(DateFormat dateFormat, Object value);
 
 /**
	Formats a object using the given DateFormat. If the value object is not a Date, it returns empty string.

    @returns formatted date string or empty string if format is not valid, never returns null
  */
  String formatSafely(DateFormat dateFormat, Date value);

}

...

Expertisefinder redirect
forcedfalse
dest{"value":"https://docs.meta-inf.hu/email-this-issue-for-jira-server-data-center/documentation/outgoing-emails/email-templates/velocity-context-in-email-templates"}
typeurl
enabledtrue

Thank you for visiting our old product documentation site. Note that we no longer store or update our documentation here.

Please navigate to our new documentation site and update your bookmarks accordingly. If you're looking for the former content of this page, click here.