Executing groovy Script into Java Jira plugin

Hello everyone,
I want to develop a Jira server plugin that with click on a button, will execute a groovy script.
How can I integrate the groovy script with my java plugin?
Thank you


Since the plugin will be programmed in JAVA you can’t always use the groovy script directly. This means that you will need to translate the script from Groovy to Java. This usually means just a couple of changes, tho. After you have translated the code, you can achieve what you need doing the following steps:

  1. Add the button to the location you want in jira (for this you will need to create a webpanel or something and add it to Jira’s interface as stated in here https://developer.atlassian.com/server/jira/platform/adding-content-to-the-jira-view-issue-page/).
  2. Create a servlet with the java code you want to execute. The servlet is nothing else that a REST endpoint that executes some JAVA code. (Servlet)
  3. in the velocity file that contains the button, you need to call the servlet as you would call any REST service. For example, you can use AJAX to make a call to that servlet’s routes when the button is clicked.

That’s a high level set of instructions, so if you need more details, please let me know.


1 Like