Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,295,565
Community Members
 
Community Events
165
Community Groups

How to create a common shared library for ScriptRunner listeners

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

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.

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

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
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

301 views 0 9
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you