Section |
---|
Column |
---|
Nunjucks is a sophisticated templating engine for JavaScript. It lets you insert dynamic content in any text through the use of templates. A template contains variables and/or expressions, which get replaced with values when a template is rendered; and tags, which control the logic of the template. See here for an overview of the templating features available in Nunjucks. Nunjucks in JMWE for JIRA Cloud is used to insert information while - Setting a field value by a post-function
- Commenting an issue by a post-function
- Conditionally executing a post-function
You can insert issue and transition information into the value using the templating features available in Nunjucks. Some basic templating features are described in this document, and more are documented on the Nunjucks website. |
Column |
---|
| Panel |
---|
borderColor | silver |
---|
bgColor | #f5f5f5 |
---|
borderWidth | 1 |
---|
borderStyle | solid |
---|
| On this page: |
|
|
...
A variable looks up a value from the template context. If you want to insert the value of a variable in your template, you can use the following syntax: {{ myVar }}
. This looks up for the myVar
variable from the context and displays it. Variable names can have dots in them which look up properties, just like in javascript.
Variables available in JMWE
JMWE makes the issue, transition, linkedIssue, parentIssue, now
and currentUser
variables available to templates. You can access their properties using "." or "[ ]". For example, you can access the current issue key using {{issue.key}}
.
issue variable
The issue
variable is used to insert data from of the issue being transitioned. You can access the issue data by looking up at its properties.
...
The transition
variable is used to insert information about of the transition being executed.
...
{{parentIssue.fields.priority.name}}
returns the priority of the parent issue being processed.
Expand |
---|
title | Click here to see the properties of the parentIssue variable |
---|
|
Properties | Description |
---|
parentIssue.id | Internal Id number of the parent issue | parentIssue.key | Parent issue key | parentIssue.fields.summary | Parent issue summary | parentIssue.fields.description | Parent issue description | parentIssue.fields.issuetype.name | Parent issue type | parentIssue.fields.issuetype.description | Parent issue Issue type description | parentIssue.fields.creator.name | Username of the person who created the parent issue | parentIssue.fields.creator.emailAddress | Email address of the person who created the parent issue | parentIssue.fields.creator.displayName | Displays name of the person who created the parent issue | parentIssue.fields.creator.timeZone | Time zone of the creator | parentIssue.fields.reporter.name | Username of the person who reported the parent issue | parentIssue.fields.reporter.emailAddress | Email address of the person who reported the parent issue | parentIssue.fields.reporter.displayName | Display name of the person who reported the parent issue | parentIssue.fields.reporter.timeZone | Time zone of the reporter of the parent issue | parentIssue.fields.assignee.name | Username of the person assigned to the parent issue | parentIssue.fields.assignee.emailAddress | Email address of the person assigned to the parent issue | parentIssue.fields.assignee.displayName | Display name of the person assigned to the parent issue | parentIssue.fields.assignee.timeZone | Time zone of the assignee of the parent issue | parentIssue.fields.created | Date and time the parent issue was created | parentIssue.fields.updated | Date and time the parent issue was last updated | parentIssue.fields.priority.name | Parent Issue priority name | parentIssue.fields.project.name | Parent Issue project name | parentIssue.fields.project.key | Parent Issue project key | parentIssue.fields.lastViewed | Date and time the parent issue was last viewed by the current user | parentIssue.fields.fixVersions[0].name | Name of the first Fix Version/s | parentIssue.fields.fixVersions[0].description | Description of the firstFix Version/s | parentIssue.fields.fixVersions[0].releaseDate | Release date of the firstFix Version/s | parentIssue.fields.versions[0].name | Name of the firstAffects Version/s | parentIssue.fields.versions[0].description | Description of the first Affects Version/s | parentIssue.fields.versions[0].releaseDate | Release date of the first Affects Version/s | parentIssue.fields.components[0].name | Name of the first component | parentIssue.fields.components[0].description | Description of the first component | parentIssue.fields.duedate | Due date | parentIssue.fields.timespent | Time spent | parentIssue.fields.timeoriginalestimate | The original estimate of the time required to resolve the parent issue | parentIssue.fields.resolution.name | Resolution of the parent issue | parentIssue.fields.watches.watchcount | The number of people watching the parent issue | parentIssue.fields.labels | Labels the parent issue relates to | parentIssue.fields.environment | The hardware or software environment the parent issue relates to | parentIssue.fields.votes | The number of votes a parent issue has |
|
...
{{
now}}
returns the current date and time, e.g. 2016-09-30T13:57:23.608Z
User-defined variables
In addition to the above variables, you can also create your own variables within the template using the set Nunjucks tag.
For example:
{% set x = "High" %}
sets the value of the variable x to High. You can also set the variable to an object. For example: {% set assignee = issue.fields.assignee %}
...
The isInGroup
filter is a custom Nunjucks filter that returns true if the user is in the specified group (passed as a parameter to the filter). The user, provided as input to the filter, can be either a username or a user object.
For example:
{{ currentUser | isInGroup("jira-administrators") }}
returns true if the current user is in the "jira-administrators" group.
...
You might also want to look at Accessing the details of an issue or a transition in Nunjucks to know how to access the details of an issue or a transition.
See here for more templating features available in Nunjucks. You might also want to refer here for use cases with Nunjucks annotations.