Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Load a Groovy Script File during Startup of Jira Server

Rituraj Nepal March 11, 2024

I have a file called helperfunction.groovy which have many functions. This file is used by many postaction scripts. In each of the scripts, I have imported the file and Used it like following : 

//Import helper functions
File helperFunctionsFile = new File("/var/application-data/jira/postaction/HelperFunctions.groovy");

Class helperFunctionsgroovyClass = new GroovyClassLoader(getClass().getClassLoader()).parseClass(helperFunctionsFile);
GroovyObject helperFunctions = (GroovyObject) helperFunctionsgroovyClass.newInstance();

 

I would like to use this GroovyObject called helperFunctions in such a way that, it would be loaded during the startup of jira server and I can use it in any postaction scripts without reloading it.  I want to use functions inside the file in as many postaction scripts as possible during the transition of issues from one transition to another. 

1 answer

1 vote
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
March 13, 2024

Hi @Rituraj Nepal

Please clarify if you intend to do this for Jira Server / DC or Cloud.

If it's for Jira Server / DC, this is doable, but for Cloud, unfortunately, at present, this is not doable.

For Jira Server / DC, you can store your Groovy code in the /scripts folder, i.e. <JIRA_HOME>/scripts, e.g. /var/lib/atlassian/application-data/jira/scripts. Once the Groovy file is added to this folder, it can be accessed from any Post-Function or Workflow. Instead of using the Inline Editor, you need to use the File tab and specify the Groovy file you intend to use.

Unlike Jira Server / DC, where you can create offline Groovy files in the /scripts folder and reuse the same file in any workflow, for Jira Cloud, for now, you can only add the code via the Inline Editor.

Hence, you must add the code separately for each workflow using the Inline Editor.

Thank you and Kind regards,
Ram

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
March 26, 2024

Hi @Rituraj Nepal

Has your question been answered?

If yes, please accept the answer provided.


Thank you and Kind regards,

Ram

Rituraj Nepal March 26, 2024

No. 

Rituraj Nepal March 26, 2024

Thanks a lot for your time :) Please keep on helping :)

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
March 26, 2024

Hi @Rituraj Nepal

As I already asked in my previous comment:-

Please clarify if you intend to do this for Jira Server / DC or Cloud.

Please clarify if you are using a Jira DC or Cloud. 

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events