Scriptrunner for Jira Server URL to return definition of custom objects

Nathan Fudenberg
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 15, 2018

In Scriptrunner for Jira Server is there any good way to extract definitions for ScriptFragments or behaviours? 

As my team builds out custom ScriptFragments we have been trying to think through our versioning system. Given that a ScriptFragment is often most complex on its "Provider class/script" section we had been manually pasting that from our source controlled repos. However the other sections are important to track as well and it would be nice to cleanly export the ScriptFragments such as retrieving the definition as json from an endpoint. 

If anyone knows a pathway whether on the Jira system, as an object that we can expose in a new endpoint, or an existing exposed url, we would love it!

1 answer

1 accepted

1 vote
Answer accepted
Aidan Derossett _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 15, 2018

Hiya Nathan! :D

We definitely provides ways to extract the definitions for both Script Fragments and Behaviours; the latter being much better documented than the former. To acquire all of your Behaviour configurations, we provide two REST Endpoints. These exist to help when migrating Behaviours, but they should be just what you're looking for. You can dig deeper into those via our documentation here.   

For Script Fragments you'll actually have to run some code in the Script Console that gets their configurations from the database. This sounds scarier than it really is. Although this method isn't well documented anywhere, all you need to do is run these three lines of code:

import com.onresolve.scriptrunner.runner.util.AOPropertyPersister
import com.onresolve.scriptrunner.fragments.FragmentsManager

return AOPropertyPersister.loadList(FragmentsManager.AO_PROPERTY_KEY) as List<Map>

However, this will usually return an unformatted, nightmarish, wall of text. So you'll probably want to add in some organized parsing by looping over and separating the returned fragment configurations.

Try both of those out and let me know how it goes! :)

Best,
Aidan

Suggest an answer

Log in or Sign up to answer