Sample Groovy scripts for asset management in Jira workflows
This page is about Assets & Inventory Plugin for Jira DC. Using Cloud? Click here.
This page provides Groovy script examples to interact with asset custom fields and Jira issues within your Jira workflows. These scripts can be used in post functions to update asset attributes based on Jira issue transitions.
You can directly use issue
or originalIssue
of the transition, or fetch an issue by key or ID with Issue Manager (like anotherIssue
in examples). return
statements are optional but it makes the script more readable.
Get Asset's Attribute value
Get Asset's Multiple Value Attribute values by name as List
Get Asset's Multiple Value Attribute values by ID as List
Get Asset's Attribute values by asset object in a loop
Â
Get "Text Field" JIRA custom field value
Get "Select List (single choice)" or "Radio Buttons" JIRA custom field value
Get "Select List (multiple choices)"Â or "Checkboxes"Â JIRA custom field values
You can directly use issue
or originalIssue
of the transition, or get another issue with IssueManager (like the example below).
 Example result: Los Angeles, San Francisco
Get old and new status name of transitioned issue
Get resolution of transitioned issue
Please note that getResolution
may be null for unresolved issues.Â
Get resolution of another issue
Get Created/Updated Date of an issue
If you want to assign a date
or dateTime
asset attribute, the value must be in ISO time format (for example, 2018-11-06T10:24:37.513
).
For Date-Time fields,
second
and rest of the value will be purged automatically. Result example:Â2018-11-06T10:24
.For date fields,
minute
and rest of the value will be  purged automatically. Result example:Â2018-11-06
.
Get Reporter/Assignee user name of an issue
If you want to assign a date
or dateTime
asset attribute, the value must be in ISO time format (for example, 2018-11-06T10:24:37.513
).
For Date-Time fields,
second
and rest of the value will be purged automatically. Result example:Â2018-11-06T10:24
.For date fields,
minute
and the rest of the value will be purged automatically. Result example:Â2018-11-06
.
Get Current datetime
If you want to assign a date
or dateTime
asset attribute, the value must be in ISO time format (for example, 2018-11-06T10:24:37.513
).
For Date-Time fields,
second
and the rest of the value will be purged automatically. Result example:Â2018-11-06T10:24
.For date fields,
minute
and the rest of the value will be purged automatically. Result example:Â2018-11-06
.