Asset generic Groovy script
This page is about Assets & Inventory Plugin for Jira DC. Using Cloud? Click here.
This guide explains how to use the [AIP] - Asset generic Groovy script post function to update asset objects when an issue transitions in your Jira workflow.
Add post function
Navigate to your desired workflow in Jira.
Locate the Post Function section.
Add a new post function named [AIP] - Asset generic Groovy script.
The Groovy script runs only once (not for each asset). All the matching custom fields with asset objects are passed to the post function as a context parameter.
Use the provided Groovy script editor to write your custom logic for updating the asset(s). Refer to the Sample Groovy scripts for examples.
Put the post function in the middle after Issue Updates and before GenerateChangeHistoryFunction and Re-index post functions.
Script context parameters
The script has access to several variables containing information about the issue and assets:
Parameter | Description |
---|---|
Asset custom fields (with values) to inject as script parameter | Select the asset custom fields to inject as script parameters. Leave it blank to include all asset custom fields. See context parameters for more information. |
Groovy script | This is the script to be executed. |
Context parameters for Groovy scripts
Refer to Sample Groovy scripts for asset management in Jira workflows for more examples.
Variable Name | Description |
---|---|
| List of custom fields with values. Its type is See ScriptRunner Groovy examples and Sample Groovy scripts for asset generic Groovy script post function for examples. |
| Access current issue. Instance of |
| Access original issue before the transition. Instance of |
| Access Jira components. See the Atlassian documentation. |
| Access Jira Custom Field Manager class. See the Atlassian documentation. |
| ApplicationUser instance for the currently logged-in user. See the Atlassian documentation. Example: |
| Default implementation of a change holder. It is used to update a custom field. |
| Helper class for the post function Groovy script. See aipUtils for details. |
Try Groovy scripts
You can immediately execute a Groovy script to see the result. This will let you write and try your Groovy scripts faster.