Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Current »

Anything related to issue must be placed inside issue cycle like this:

{{foreach[issue in issues]}}

  Insert issue fields here

  Issue: {{[issue.issuekey]}}

  Summary: {{[issue.summary]}}

{{/foreach}}

Where {{foreach[issue in issues]}} is start of the cycle, and {{/foreach}} is the end.

Fields

To insert fields in a template, please use the following syntax:

Email of issue assignee

{{[issue.assignee.email]}}

Issue summary

{{[issue.summary]}}

Custom fields look like this:

{{[issue.customField("customfield_10029")]}}

It's better to insert field, using our Template editor which allows to pick the required field from the list.

Formatting

Some fields can be formatted depending on field's type. Date and date time fields are formatted with Java Date Time pattern like this:

{{[issue.created]:"dd/MMM/yy h:mm a"}}

{{[issue.customField("customfield_10030")]:"d/MMM/yy"}}

If formatting is not specified default format from settings will be used. 

Number fields can be formatted with Java DecimalFormat pattern.

{{[issue.timespent]:"#"}}

Conditional expressions

Use conditional expressions to generate generate document based on some conditions. Conditional expressions can use following keywords {{if}} {{elseif}} {{else}} {{/if}}. In simple conditional expressions you can skip {{elseif}} and {{else}}.

{{if [issue.issuetype.name == "Epic"]}}
      This is an Epic
{{elseif [issue.issuetype.name == "Story"]}}
      This is a Story
{{else}}
      This is a Task
{{/if}}

In simple conditional expressions you can skip {{elseif}} and {{else}}.

{{if [issue.issuetype.name == "Epic"]}}
      This one is an Epic
{{/if}}

Custom fields in expressions

Usual operations like +, -, *, /, == can be used for regular fields. But custom fields require special handling.

Numeric fields must be prefixed with "(double)" to work correctly. For example:

{{if[(double)issue.customField("customfield_10520") == 123]}}
      Number is 123
{{else}}
      Number is not 123
{{/if}}

Text fields must be prefixed with "(String)" to work correctly. For example:

{{if[(String)issue.customField("customfield_10521") == "apple"]}}
      You have an apple.
{{else}}
      You have an orange.
{{/if}}

Iterating lists

Sometimes, Jira data is a list of multiple objects. For instance, 'comment' and 'work log'.

To be able to insert such data, it must be placed inside a cycle.

{{foreach [worklog in issue.worklogs]}}
  {{[worklog.timeSpent]}}
{{/foreach}}}

In example above, worklogs is the list. The code will take issue worklogs one by one, and temporary store it under name worklog. Then it will display timeSpent property of the worklog. As a result, time spent will be shown for all the issue worklogs.

Example of comment:

{{foreach [comment in issue.comments]}}
  {{[comment.body]}}
  {{[formatDateTime(comment.created)]}}
  {{[comment.author.displayName]}}
  {{[comment.author.name]}}
  {{[comment.author.emailAddress]}}
{{/foreach}}}

There are two custom field types that must be placed inside a cycle: Labels and Select List (multiple choices). They are basically lists of text fields. In general, they will look like this:

{{foreach[item in issue.customFieldArray("customfield_10036")]}}

  {{[item]}}

{{/foreach}}

Page break

You can insert page brake at certain point of the document. 

{{[_PAGE_BREAK_]}}

If you are using Template editor it can be done by clicking 'Page break'.

Extension methods

You can group, sort, and perform other sequential data manipulations in template expressions. See Extension methods for more.

Common templates for different field types

User

{{[issue.reporter.displayName]}}
{{[issue.reporter.name]}}
{{[issue.reporter.emailAddress]}}
{{[issue.reporter.timeZone]}}

Comment

{{foreach [comment in issue.comments]}}
  {{[comment.id]}}
  {{[comment.body]}}
  {{[formatDateTime(comment.created)]}}
  {{[formatDateTime(comment.updated)]}}
  {{[comment.author.displayName]}}
  {{[comment.author.name]}}
  {{[comment.author.emailAddress]}}
  {{[comment.author.timeZone]}}
  {{[comment.updateAuthor.displayName]}}
  {{[comment.updateAuthor.name]}}
  {{[comment.updateAuthor.emailAddress]}}
  {{[comment.updateAuthor.timeZone]}}
{{/foreach}}

Worklog

{{foreach [worklog in issue.worklogs]}}
  {{[worklog.id]}}
  {{[formatDateTime(worklog.created)]}}
  {{[formatDateTime(worklog.updated)]}}
  {{[formatDateTime(worklog.started)]}}
  {{[worklog.timeSpent]}}
  {{[worklog.timeSpentSeconds]}}
  {{[worklog.author.displayName]}}
  {{[worklog.author.name]}}
  {{[worklog.author.emailAddress]}}
  {{[worklog.author.timeZone]}}
  {{[worklog.updateAuthor.displayName]}}
  {{[worklog.updateAuthor.name]}}
  {{[worklog.updateAuthor.emailAddress]}}
  {{[worklog.updateAuthor.timeZone]}}
{{/foreach}}

Progress

{{[issue.progress.progress]}}
{{[issue.progress.total]}}
{{[issue.progress.percent]}}

Other properties (custom, etc.)

{{[getStringProperty(objectToMap(issue.issueModel.fields), "customfield_13509.displayName")]}}

The example above will show displayName property of custom field 13509
So you will have to change text in bold to match your property name.

  • No labels