Velocity Context for Email Templates

JIRA 3.6 introduced the TemplateContext and TemplateIssue objects into the Velocity context available for each email template.

The TemplateContext provides access to some general object references for use in the templates - e.g. Utilities,  Change Log details, etc.

The TemplateIssue provides access to the Issue object - further extended by helper methods for displaying information in rendered HTML format (i.e. environment, description and comments) and users who may not exist in the system. All issue related details can be retrieved from the TemplateIssue.

The following tables lists other objects that are also available within the context:

Velocity Variable

JIRA Object/Value

Description

userutils

com.atlassian.core.user.UserUtils

collection of utility methods for querying, creating, and removing users

velocityhelper

com.atlassian.jira.util.JiraVelocityHelper

a collection of miscellaneous methods (e.g. urlencode, indentTextBlock, printChangelog

textutils

com.opensymphony.util.TextUtils

collection of utility functions for manipulating text

constantsManager

com.atlassian.jira.config.ConstantsManager

JIRA's constants for priorities, resolutions, issue types, statuses

projectManager

com.atlassian.jira.project.ProjectManager

management of project entities (e.g. getProjectByName, getComponents, getCategories)

customFieldManager

com.atlassian.jira.issue.CustomFieldManager

functions for working with custom fields

applicationProperties

com.atlassian.jira.config.properties.ApplicationProperties

access JIRA's application properties

jirautils

com.atlassian.jira.util.JiraUtils

a handful of miscellaneous utility methods (e.g. isPublicMode, isSetup)

jirakeyutils

com.atlassian.jira.util.JiraKeyUtils

methods for working with project keys

buildutils

com.atlassian.jira.util.BuildUtils

buildutils is no longer available within the context. build variable should be used instead (see below)

build

com.atlassian.jira.util.BuildUtilsInfo

Since JIRA 6.1 JIRA build and edition information

jiraUserUtils

com.atlassian.jira.user.util.UserUtil

user level operations (e.g. getActiveUserCount, getDisplayableNameSafely, addUserToGroup)

mailPluginsHelper

com.atlassian.jira.mail.JiraMailPluginsHelperImpl

method for checking whether plugins are enabled

userformat

com.atlassian.jira.plugin.profile.UserFormatManager

formatting user names

context

com.atlassian.jira.mail.TemplateContext

The Template Context object itself

issue

com.atlassian.jira.mail.TemplateIssue

An Issue object with extended helper methods for display - this is the issue for which the email notification event was triggered

params

java.util.Map

Parameters of the IssueEvent that triggered this email notification

remoteUser

com.opensymphony.user.User

The user who has triggered this event

stringUtils

org.apache.commons.lang.StringUtils

Utility object providing formatting methods

padSize

java.lang.Integer

Used in text emails for padding the display

timeSpentFieldId

java.lang.String

The Id of the TimeSpentField - used in changelog for work logged notifications

attachments

Collection(org.ofbiz.core.entity.GenericValue)

Collection of Generic Values that represents the attachments associated with the issue

htmlComment

java.lang.String

The comment associated with this event as a rendered HTML formatted string. A basic string is returned if the comment cannot be rendered correctly - including links for any referenced JIRA issues.

comment

com.atlassian.jira.issue.comments.Comment

The comment associated with this event. The body of the comment will be the raw unprocessed comment as entered by the user (e.g. the raw wiki markup)

commentauthor

com.opensymphony.user.User

The author of the comment 

roleVisibilityLevel

java.lang.String

The comment's project role level (overwritten by worklog)

groupVisibilityLevel

java.lang.String

The comment's group level (overwritten by worklog)

originalhtmlComment

java.lang.String

originalcommentauthor

com.opensymphony.user.User

originalroleVisibilityLevel

comment (overwritten by worklog)

originalgroupVisibilityLevel

comment (overwritten by worklog)

worklog

com.atlassian.jira.issue.worklog.Worklog

timeSpentUpdated

java.lang.Boolean

startDateUpdated

java.lang.Boolean

commentUpdated

java.lang.Boolean

visibilityUpdated

java.lang.Boolean

originalworklog

com.atlassian.jira.issue.worklog.Worklog

changelog

org.ofbiz.core.entity.GenericValue

The Generic value representing the changelog associated with the change

changelogauthor

com.opensymphony.user.User

The change log author

security

org.ofbiz.core.entity.GenericValue

The Generic value representing the security level, if any, associated with this issue

rendererManager

com.atlassian.jira.issue.RendererManager

JIRA 3.13.3 onwards! allows use of renderers such as wiki renderer. (e.g. $rendererManager.getRenderedContent("atlassian-wiki-renderer", "bold wiki", $issue.getIssueRenderContext()))

recipient

com.opensymphony.user.User

The recipient of the email

i18n

com.atlassian.jira.utilI.I18nHelper

i18n translation helper for the current recipient

dateformatter

com.atlassian.jira.web.util.OutlookDate

Date and time formatter for the current recipient's locale

eventTypeName

java.lang.String

Available from JIRA 4.1. The localised event type name. (For example, for the Issue Assigned event, the key mail.event.type.issueassigned.name will be used.) If a translation is not available, the event type name will be used

attachmentsManager com.atlassian.jira.mail.util.MailAttachmentsManager Available from JIRA 7.0.3. If this object is present, the mail attachments manager can be used to add attachments to an email and generate Content-IDs for those attachments.
Was this page helpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport