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!
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
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.