A focus of ScriptRunner 3 is being able to script other plugins, for instance JIRA Agile (Greenhopper), Structure, etc etc.

There are two annotations that allow this. The first is @WithPlugin(pluginKey) , which will effectively make classes provided by the target plugin available to your script.

The second is @PluginModule, which injects an instance of this module in to your script.

These annotations only work when running a script that is under a script root…​ not a script outside a script root, nor code pasted into the console.
JIRA Agile is a special case - see Working With JIRA Agile.


This is an annotation that you can put in your or on a class. It takes the plugin key as an argument. You can get the plugin key from Manage Plugins:

image2014 3 26%2014%3A46%3A1

When this annotation is present, the classloader for the target plugin is added to the list of classloaders when your script is compiled and run, so your imports from eg the Structure plugin will be resolved.

Currently there is no way to make this fail quietly if the plugin you request is not present - vote for - if this is an issue.


Annotating a variable in a class or a script, will inject an instance of this type into your script. This is most commonly used for getting hold of a module defined in another plugin. In a traditional plugin you would use <component-import> to achieve the same thing.

If you are working with Structure you may use:

import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.almworks.jira.structure.api.StructureServices
StructureServices structureServices

Structure is quite easy because given a StructureServices you can get all the other services from that.

Do not initialise the variable yourself, eg:

StructureServices structureServices = null

will produce an error:

startup failed: General error during semantic analysis: Cannot set plugin module when field already initialised

If you are working with Intellij IDEA you may get a warning about uninitialised variables:

image2014 3 26%2015%3A10%3A11

You can disable this with //noinspection GroovyVariableNotAssigned on your first use of the variable.

For how-to questions please ask on Atlassian Answers where there is a very active community. Adaptavist staff are also likely to respond there.

Ask a question about ScriptRunner for JIRA, for for Bitbucket Server, or for Confluence.