How to create a common shared library for ScriptRunner listeners

Luis Castillero November 4, 2020

I am creating several listeners within my instance which some would benefit from having a shared library of utility functions that I can use in different listeners to avoid code repetition (DRY).

I know that I could create a single script and do what's needed based on the event type, but it will be a big script and I want to keep it simple (KISS).

Is there a way of writing reusable code in the scriptrunner scripts? I know I can define shared constant values, but I am not sure about functions

1 answer

1 accepted

0 votes
Answer accepted
Danyal Iqbal
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 4, 2020

I would start  thinking about a custom plugin with a listener at this point. Scriptrunner is great at what it does but writing your own plugin will help you reuse code. 

P.S : you will have to remove and add the listener every time you update the class.

Kamran Ansari June 15, 2022

Hello Danyal,

I'm relatively new to plugin development but I'd like to give this a try.

Would you be able to point me to an example custom plugin with a listener that's developed solely for the purpose of reusing existing code? We have several ScriptRunner REST endpoints that share a lot of code. 

Many thanks!

Kamran

Kamran Ansari June 15, 2022

Searching further led me to this article by Alexey Matveev.

https://community.atlassian.com/t5/Jira-articles/Work-with-your-Jira-plugin-from-Adaptivist-ScriptRunner-or-how/ba-p/719050

I have just skimmed through it but I feel confident that I should be able to take it from here.

Thanks anyways!

Kamran

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events