ScriptRunner supports looking up its script roots from another plugins-2 plugin. In other words, it can automatically add the root of another plugin to its collection of script roots.

This can be useful for Atlassian Experts and partners who would like to deliver a fully functional business process to a customer, without them having to copy scripts to their server. (A better alternative to copying scripts around is to just tell the custom to clone/update a git repository).

You should be able to provide someone a workflow, which references scripts like com/atlassianexpert/acme/custy/Foo.groovy, and ship these files in a plugin.

You can checkout a working sample here: https://bitbucket.org/jamieechlin/sr-scripts-plugin

Creating a Scripts Plugin

The overview is: create a plugin in the usual way, add a dependency on ScriptRunner in the bundle instructions. ScriptRunner will detect this and automatically add it to its list of script roots. The configured script roots are displayed on the Script Console.

Detail

Create an empty plugin:

mvn com.atlassian.maven.plugins:maven-jira-plugin:4.2.10:create

Add the dependency to your plugins XML:

atlassian-plugin.xml
<bundle-instructions>
  <Require-Bundle>com.onresolve.jira.groovy.groovyrunner</Require-Bundle>
</bundle-instructions>

The following dependencies are only necessary if you want to open your POM as a project in an IDE, eg Intellij IDEA:

Add dependency on ScriptRunner with provided scope:

pom.xml
<dependency>
  <groupId>com.onresolve.jira.groovy</groupId>
  <artifactId>groovyrunner</artifactId>
  <version>3.0.0</version>
  <scope>provided</scope>
</dependency>
Use the latest released version for the version ID above. You will have to install this into your local repository or internal artifact repository. Maven will give you the commands to run when it first fails.

Add groovy-all provided dependency:

pom.xml
<dependency>
  <groupId>org.codehaus.groovy</groupId>
  <artifactId>groovy-all</artifactId>
  <version>${groovy.version}</version>
  <scope>provided</scope>
</dependency>
...
<groovy.version>2.2.1</groovy.version>

You can either add plain scripts or "built-in scripts" which can be parameterised, implementing CannedScript. Don’t forget to add your canned scripts to the correct package.

When developing, add a script root for the resources dir of your plugin to speed development turnaround time using the system property.

Caveats

There are some problems with this at the moment, please give me feedback as this is a new feature.

  • If you disable ScriptRunner plugin your plugin will be disabled, and won’t be enabled when you re-enable ScriptRunner

  • If you disable your plugin, the scripts it provides will still be available