DGJ Server: Template syntax

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]:"#"}}

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]}}