Adding post function
...
Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
This page is about Assets & Inventory Plugin for Jira DC. Using Cloud? Click here. |
This guide explains how to configure the [AIP] - Create Asset workflow
...
post function
...
to automatically create new assets in Jira when specific workflow transitions occur and, optionally, attach to the current issue.
...
Put the post function in the middle; after issue creates and before "Update change history for an issue and store the issue in the database." .
Table of Contents |
---|
Workflow Parameters
...
On this page:
|
---|
Add the post function
Navigate to the desired workflow in Jira.
Locate the workflow editor and identify the transitions where you want assets created.
Drag and drop the [AIP] - Create Asset workflow post function after the Create Issue step and before the Update change history step.
Configure the post function
The post function has several settings to define how assets are created:
Workflow parameters
Parameter | Description |
---|---|
Condition 1 | Groovy script for the post function condition. |
...
The function must return true, or condition must be empty to pass. If the condition fails, the post function will be ignored. | |
Condition 2 | Asset custom field value must be empty before the transition. |
Link to issue | Set newly created asset to asset custom field. |
Target Asset custom field | Specify the custom field to link the asset. |
Asset Type | Type of asset to create. |
Attributes (optional) | Target attribute to set |
...
its value. |
Context parameters for Groovy
...
scripts
This table details the available context parameters you can leverage within your scripts. Please see Sample Groovy
...
scripts for asset management in Jira workflows for more examples.
Variable Name | Description |
---|---|
issue | Access current issue. Instance of |
...
Refer to the Atlassian documentation. | |
originalIssue | Access the original issue before the transition. Instance of |
...
Refer to the Atlassian documentation. | |
ComponentAccessor | Access |
...
Jira components. |
...
Refer to the Atlassian documentation. | |
customFieldManager | Access |
...
Jira Custom Field Manager class. |
...
Refer to the Atlassian documentation. | |
loggedInUser | ApplicationUser instance for current logged-in user. |
...
Refer to the Atlassian documentation. Example: |
...
|
...
|
...
| |
DefaultIssueChangeHolder | Default implementation of a change holder. |
...
It’s used to update a custom field. | |
aipUtils | Helper class for the post function |
...
Groovy script. |
...
Refer to aipUtils for details |
...
. |
Sample Post Function configuration page
Here is an example of all types of attributes.
...
Try Groovy
...
scripts
You can immediately execute
...
a Groovy script
...
to see the result. This will let you write and try your
...
own Groovy scripts faster.
Please
...
remember that scripts will be actually executed
...
. If you modify anything, please use test objects (issue, asset, etc.)
...
.
Groovy examples for
...
asset Attribute
...
types
...
Attribute Type | Description | Groovy example |
---|
...
Cascading Dropdown | The value must be cascading dropdown option IDs. Add | return "1-2" |
CheckboxList | Return valid option values wrapped with three |
...
“@” characters. |
...
For example: For a single option value |
...
, you don’t need to wrap with |
...
DatePicker
...
import java.time.*
LocalDateTime t = LocalDateTime.now();
return (t as String)
return "ada@@@@@@ist" | |
DatePicker | The result must be in ISO format ("yyyy-MM-dd") |
...
. For example, You do not need to |
...
format if you use the LocalDateTime class, as it returns in ISO format by default. |
...
import |
...
java.time.* |
...
...
LocalDateTime |
...
t |
...
= |
...
LocalDateTime.now(); |
...
return |
...
(t |
...
as |
...
String) |
...
DateTimePicker |
...
The result must be in ISO format ("yyyy-MM-ddTHH:mm") |
...
. For example, You do not need to do formatting if you use the LocalDateTime class, as it returns in ISO format by default.
|
...
import java.time.* LocalDateTime t = LocalDateTime.now(); return (t as String) | ||
DropdownList | Return a valid option value. |
...
return "ada" | ||
Encrypted | The value must be text. | return |
...
" |
...
password123" | |
InventoryList | Return reference asset ID |
...
. | return |
...
" |
...
3" | ||
InventoryListByForm | Return reference asset ID. | return "10" |
IP |
...
Any text is possible, there is no format control. | return "10.0.0.2" |
IPv6 | Any text is possible, there is no format control. |
...
return |
...
"2001:0db8:85a3:0000:0000:8a2e:0370:7334" |
...
return "izm"
...
return "ada@@@@@@ist"
...
Return valid option values wrapped with three @ characters. i.e: @@@ada@@@@@@ist@@@
For a single option value no need to wrap with @ characters.
...
Jira Organizations | The value must be one of Jira Organization IDs. If there are multiple values, you must add "@@@@@@" between them.
| return "1" return "1@@@@@@2" | ||
Jira Project | The value must be one of Jira Project IDs. If there are multiple values, you must add "@@@@@@" between them.
| return "10000" return "10000@@@@@@10001" | ||
Jira Project Components | The value must be one of "Jira Project Id - Jira Project Component Id". If there are multiple values, you must add "@@@@@@" between them.
| return "10000-1" return "10000-1@@@@@@100001-2" | ||
Jira Project Versions | The value must be one of "Jira Project Id - Jira Project Version Id". If there are multiple values, you must add "@@@@@@" between them.
| return "10000-1" return "10000-1@@@@@@100001-2" | ||
Jira User Picker | The value must be a username. It doesn't need to be a Jira User. | return "tyler-durden" | ||
RadioButtonList | Return a valid option value. | return "ist" | ||
Text | Any text is possible. | return issue.summary | ||
TextArea | Any text is possible. |
...
return |
...
issue.description | |
URL | Any text is possible, there is no format control. |
...
return |
...
"http://www.snapbytes.com/" |
...
UserPicker |
...
return issue.reporter.username
Any text is possible, there is no control. You may use | return issue.reporter.username |