Groovy Runner

Name Groovy Runner
Version 1.0
Product Versions tested on JIRA 3.8.1
Author(s) Patrick Roumanoff
Homepage http://roumanoff.com/atlassian/
Price Free
License BSD
JavaDocs #N/A
IssueTracking #N/A
Download JAR groovy-runner-1.0.jar
Download Source groovy-runner-1.0.tar.gz

Description/Features

This plugin is providing administrators a panel similar to the Jelly Runner, except it will interpret Groovy script to be run on the server.
I always found Jelly Script impossible to read and impossible to write, even though I have written some maven 1 plugins using this language, it was particularly painful. XML is definitively not a programming language!
As Groovy is getting to be approved as JSR-241 I thought this would be a good contribution to JIRA, modernizing the available scripting engines available to administrators and plugin developpers.

Comments/Criticisms welcome at patrick.roumanoff@gmail.com

Usage

Copy the plugin jar to WEB-INF/lib along side groovy-all-1.0.jar, restart and you are ready to go.
You need to be administrator in order to use the plugin (but you are; isn't it otherwise you shouldn't be allowed to install plugins and restart the server.)
Click on 'Administration', and expand the 'Options and settings' category, then choose 'Groovy Runner'. There is a default script provided to give a feel of what you can do.

Access to JIRA api

There is a number of JIRA Managers which are available to your groovy scripts as defined variables:

I also defined those variables in case they would be useful:

Getting Feedback

If you want some feedback from the execution, either return an object from the script (a toString() will be displayed on the result page) or use print statements and look for output in the server log.

If the script fail for some reason, the exception message will be displayed in the result area, and a stack trace will be dumped in the logs.

To Learn about Groovy syntax, you can check out the official website

Examples

result=""
for(p in projectManager.projects) {
  result += "Project $p.name id is $p.id\n";

}
return result

This script will iterate over all the projects and display one line per project with the project name and the project Id

Version History

1.0 : initial release

Screenshots

Labels

codegeist_2007_jira codegeist_2007_jira Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jul 06, 2007

    Mark Michaelis says:

    I totally agree that writing Jelly scripts is weird. Would be great to use Groov...

    I totally agree that writing Jelly scripts is weird. Would be great to use Groovy instead. But trying your example script results in:

    HTTP Status 404 - Could not execute action [GroovyRunner]:groovy/lang/Binding<p><small><small><pre>java.lang.NoClassDefFoundError:
      groovy/lang/Binding at com.roumanoff.jira.groovy.GroovyRunner.doExecute(GroovyRunner.java:58)
     at webwork.action.ActionSupport.execute(ActionSupport.java:153)
     at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:54)
     at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:132)
     at com.atlassian.jira.web.dispatcher.JiraServletDispatcher.service(JiraServletDispatcher.java:209) 
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    [...]
    

    (Jira 3.9.3)

    1. Jul 08, 2007

      Patrick Roumanoff says:

      looks like you are missing the groovy jar...

      looks like you are missing the groovy jar...

  2. Jul 20, 2007

    David Derumier says:

    I have the same problem ! Could you verify the JAR file? 7KB is really ... ...

    I have the same problem !

    Could you verify the JAR file? 7KB is really ... small for a script interpreter

    1. Jul 20, 2007

      Bob Swift says:

      Instructions say to install the groovy jar ...

      Instructions say to install the groovy jar ...

  3. Nov 15, 2007

    Joshua Goodall says:

    Needs recompiling for 3.10 or later, I believe.

    Needs recompiling for 3.10 or later, I believe.

  4. Apr 08, 2008

    Mark Shabelman says:

    I'm trying to get groovy runner working on jira 3.12 but getting the "java.lang...

    I'm trying to get groovy runner working on jira 3.12 but getting the "java.lang.NoSuchFieldError: log" error when trying to run the sample script

    i got brand new 3.12.2 standalone today and both groovy-all-1.5.4.jar and groovy-runner-1.0.jar in the lib

    here is the error :

    2008-04-08 09:53:31,671 http-8080-Processor24 ERROR [webwork.dispatcher.ServletDispatcher] Could not execute action
    java.lang.NoSuchFieldError: log
        at com.roumanoff.jira.groovy.GroovyRunner.doExecute(GroovyRunner.java:57)

    then i changed the log for webwork.dispatcher.ServletDispatcher to debug and this is what i get now:

    2008-04-08 09:55:24,870 http-8080-Processor23 DEBUG http://webwork.dispatcher.ServletDispatcher Result:/secure/admin/views/viewlogging.jsp
    2008-04-08 09:55:47,557 http-8080-Processor25 DEBUG http://webwork.dispatcher.ServletDispatcher Result:/templates/groovy/groovy_runner.vm
    2008-04-08 09:55:48,901 http-8080-Processor25 ERROR http://webwork.dispatcher.ServletDispatcher Could not execute action
    java.lang.NoSuchFieldError: log

  5. Jun 08

    Dennis Portello says:

    While looking for a plugin where I could create workflow elements using Groovy, ...

    While looking for a plugin where I could create workflow elements using Groovy, I found this plugin. It's not quite what I wanted but found it to be indispensable. I recently had to merge 3 large project with over 5000+ tickets into a single project. While migrating the projects, some of the version and components were lost. I was able to view the change logs for the missing components and set the equivalents in the new project.

    Getting this to work wasn't easy for 3.12.1, it require a recompile. The problem was, I couldn't get the old style PDK to work, so I had to convert it over to the maven 2 style PDK. I saw that someone else was working on workflow elements utilizing groovy and was considering merging this project into it. If they don't do that, I've considered adding JRuby, Jython, and Rhino support.  

  6. Jun 11

    Bill Greene says:

    I had the same problem as Mark did with JIRA 3.12, but it seems to work after I ...

    I had the same problem as Mark did with JIRA 3.12, but it seems to work after I recompiled with the JIRA 3.12 plugin development kit.  I attached this jar as "groovy-runner-1.1.jar"

    1. Oct 23

      Bruno Blaise says:

      Hi Bill,  Is-it possible to produce a groovy-runner-1.2.jar for JIRA 3.13 ...

      Hi Bill,

       Is-it possible to produce a groovy-runner-1.2.jar for JIRA 3.13 ?

      I did a test with JIRA 3.13 and I have the same problem and it does not work with groovy-runner-1.2 neither

      Bruno

  7. Aug 20

    Marc Paquette says:

    I'm looking into some guidance for converting existing jelly scripts into groovy...

    I'm looking into some guidance for converting existing jelly scripts into groovy ones : I'm fluent with the groovy language itself, I am just wondering how to use the jira jelly tags (like <jira:AddComponent ...> or <jira:CreateIssue...>) from groovy scripts. Is it even possible or do I have to use java API directly ?