スマート バリューとは
Smart values allow you to access and manipulate issue data within Jira. They can add significant power and complexity to your rules. For example, the smart value {{now.plusDays(5)}}
references the current time and adds 5 days to it. and {{issue.summary}}
will print off the summary of the issue.
例
You can use smart values to add a comment to an issue on transition, addressing the name of the reporter and assignee of the issue.
Hi {{reporter.displayName}}
We're now looking into your issue {{issue.summary}}.
We'll get back to you soon with an update.
{{assignee.displayName}}
スマート バリューをフォーマットする
Smart values use the Mustache library, preventing arbitrary code execution. To make a substitution, you need to wrap the value in double curly brackets, e.g. {{value}}
.
Use a period to reference child elements, e.g. {{issue.key}}
.
Finding a smart value
For the majority of cases, you can choose a smart value from our reference documentation:
- For smart values related to issue data, see Smart values - general.
- For smart values related to lists and properties that contains multiple values (e.g.: comments, fix versions, watchers), see Smart values - lists.
- For smart values related to text fields (e.g.: summary, comments), see Smart values - text fields.
- For smart values related to user data (e.g.: assignee, reporter), see Smart values - users.
- For smart values related to development information (e.g.: builds, pull requests), see Smart values - development.
- For smart values related to date and time, see Smart values - date and time functions
- For smart values related to numerical expressions, see Smart values - math expressions
- For smart values related to JSON functions, see Smart values - JSON functions
You can access the value in custom fields using the custom field's name, e.g. {{issue.Team Leader}}
. Field names are case insensitive and are translated using your rule actor's language setting. Learn more about accessing issue fields.
If your instance is highly customized, you will need to investigate the REST API to find the right smart value. Learn more about finding the smart value for field.
Testing a smart value
To test what a smart value returns:
- Create a rule using the Manual trigger with Log action action.
- Navigate to an issue, and select Rule executions to manually trigger your rule.
- The result displays in the audit log, as shown below.
Chaining smart value functions
You can apply multiple transformations in one step by chaining your smart functions.
You can change an issue’s summary to lowercase, only use the first 10 characters, and add !! to the end using the following example.
{{issue.summary.toLowerCase().substring(0, 10).concat("!!")}}
Using smart values with sections and lists
When working with smart values that have multiple items, you can use # with the smart value to apply your rule to every item in the list. For example, the smart value {{issue.comments}}
is used to access and return an issue's comment. However, if the issue has multiple comments, the smart value {{#issue.comments}}
would make your rule iterate on each comment individually. When using #, you must close the expression with {{/}}.
For example, to print a list of comment authors:
{{#issue.comments}}Author: {{author.displayName}}{{/}}
To treat items as numbers, use {{#=}}
when using a math function. For example, to add 100 to an Invoice amount custom field:
{{#=}}{{issue.Invoice Amount}} + 100{{/}}
既定値
If a field or value doesn't exist, it will return an empty value: {{invalid reference}}
. You can specify a default value to prevent this.
For example, when invalid reference doesn't contain a value, you can print Hello world using {{invalid reference|"Hello world"}}
.
Create your own smart values
You can define your own custom smart values using the Create variable action.
詳細
Check out how we use smart values in our Jira automation template library.