Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Assets And Inventory plugin offers flexible post functions to update asset objects with JIRA workflows. If post function fails to execute, it will be ignored and logged.

Asset post functions start with [AIP].

Image Removed

Table of Contents

 

1- [AIP] - Update Asset workflow post function

Add "[AIP] - Update Asset workflow postfunction" to the workflows to update an asset object on transition.

Please put the post function in the middle; after issue updates and before GenerateChangeHistoryFunction and Re-index post functions.

Image Removed

Parameters

...

Specify the custom field to update assets. Leave it blank to update all Asset custom fields.

...

This is the default script to be executed for the options that has no specific groovy script. Type script returning the value to update asset attribute, e.g return issue.summary

...

Form: Define specific Form or select "Any form" to update the assets having the attribute.

Attribute: Target attribute to set it's value

...

Groovy Scripts to execute

(one for each attribute definition)

There 2 options to use as source value:

...

JIRA Custom field value will be added later as 3rd value source.

Context parameters for Groovy Scripts

Please see Sample Groovy Scripts for more examples.

...

Access AIP asset class instance. Only valid for Default Groovy Script and Attribute Groovey Script. See https://confluence.snapbytes.com/x/-YZ2AQ.

...

Access current issue. Instance of com.atlassian.jira.issue.Issue. see https://docs.atlassian.com/software/jira/docs/api/7.6.1/index.html?com/atlassian/jira/issue/Issue.html

...

Access original issue before the transition. Instance of com.atlassian.jira.issue.Issue. see https://docs.atlassian.com/software/jira/docs/api/7.6.1/index.html?com/atlassian/jira/issue/Issue.html

...

Access JIRA Custom Field Manager class. See https://docs.atlassian.com/software/jira/docs/api/7.6.1/index.html?com/atlassian/jira/issue/CustomFieldManager.html

...

ApplicationUser instance for current logged in user. See https://docs.atlassian.com/software/jira/docs/api/7.6.1/index.html?com/atlassian/jira/user/ApplicationUser.html

Example:

 loggedInUser == issue.getAssignee()

 

Sample Post Function configuration page

Image Removed

You can add multiple post functions or multiple attributes for one post function.

Try Groovy Script

You can immediately execute groovy script so see result. This will let you write and try your groovy scripts faster. Please keep in mind that scripts will be actually executed, if you modify anything please use test objects (issue, asset, etc.)!

Groovy examples for Asset Attribute Types

...

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.

...

DatePicker

...

import java.time.*  
  LocalDateTime t = LocalDateTime.now();  
  return (t as String) 

...

Result must be in ISO format ("yyyy-MM-dd"), i.e: "2018-12-26".

You do not need to do formatting if you use LocalDateTime class as it returns in ISO format by default.

...

import java.time.*  
  LocalDateTime t = LocalDateTime.now();
  return (t as String) 

...

Result must be in ISO format ("yyyy-MM-ddTHH:mm"), i.e: "2018-12-26T20:20".

You do not need to do formatting if you use LocalDateTime class as it returns in ISO format by default. If you need to format a date to string, use the format as: "yyyy-MM-dd'T'HH:mm" (Please notice extra single quotes!)

...

return "ada"

...

return "3"

...

return "10"

...

return  "10.0.0.2"

...

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.

...

return "ist"

...

return issue.summary

...

return issue.description

...

return "http://www.snapbytes.com/"

...

return issue.reporter.username

...

 

 

Another post function example for All Attribute types

You can update all fields of an attribute in one post function.

...

Panel
panelIconIdatlassian-info
panelIcon:info:
panelIconText:info:
bgColor#F4F5F7

This page is about Assets & Inventory Plugin for Jira DC. Using Cloud? Click here.

This document explains how to leverage the Assets & Inventory Plugin's post functions to automate asset management within your Jira workflows.

Available post functions

  1. Create Asset: This function allows you to automatically create a new asset object when a specific transition occurs in your workflow.

  2. Update Asset: This function enables you to update existing asset information based on workflow transitions. You can update various asset details, including associated issues, JIRA components, and custom fields.

  3. Asset Generic Groovy Script: This function provides advanced users with the ability to execute custom Groovy scripts to manipulate asset data during workflow transitions.

Important notes

  • In case a post function encounters an error during execution, it will be skipped and logged for troubleshooting purposes.

  • All Assets & Inventory Plugin post functions are easily identifiable by the prefix "[AIP] - ".

    Image Added