A focus of ScriptRunner is being able to script other plugins, for instance, Jira Software, Structure, etc.

Two annotations allow this. The first is @WithPlugin(pluginKey), which effectively makes classes provided by the target plugin available to your script.

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

Jira Software is a special case (see Working With Jira Agile).


Add this annotation to your script or on a class. It takes the plugin key as an argument. You can get the plugin key from the Manage Plugins screen:

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 the script is compiled and run. Meaning imports from, for example, the Structure plugin, will be resolved.


Annotating a variable in a class or a script injects 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 this.

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, for example:

StructureServices structureServices = null

This produces 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.

Have questions? Visit the Atlassian Community to connect, share, and learn with other Atlassian users and experts, including Adaptavist staff.

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

Want to learn more? Check out courses on Adaptavist Learn, an online platform to onboard and train new users for Atlassian solutions.