Creating a Script Plugin for JIRA 6

I develop scripts for JIRA 6.0.1 and want to create a script plugin with ScriptRunner. For JIRA 7 it works perfect but I have a problem with the old version. 

What version of script runner (neither 2.1.15 nor 3.0.16 works) and gmavenplus-plugin should I use? 

5 answers

This widget could not be displayed.

Hi Wero,

You can use the  ScriptRunner versions 3.* free and compatible with JIRA 6.3.* to create scripted plugins. 

But I see your point, SR v3.0.16 may be not compatible with JIRA v6.0.1 and you cannot use the SR v2.* for creating scripted plugins. 

Hope that makes sense.

Regards, Thanos

This widget could not be displayed.

Thank you Thanos for your answer.

Do you think there is no possible to make a plugin, which puts all script to the ScriptRunner directory? I don't have access to the JIRA directory and I can't copy those files.

 

Regards,

Wero

Hi Wero, 

What about, as a possible workaround, to configure additional script roots and place your scripts under those ?

regrads, Thanos

This widget could not be displayed.

Hi Thanos,

I read about script roots and I am wondering how I can get those scripts from my plugin? I am trying to read a script from script console but the file path couldn't be found (The system cannot find the path specified or The filename, directory name, or volume label syntax is incorrect). Should I use something like plugin://KEY.TO.MY.PLUGIN/ ? 

What should I set in the file setenv.bat? 

 

Regards,

Weronika

Hi Weronika,

To be honest the easiest way to do this is in your plugin pom to have something like 

<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>

<systemPropertyVariables>
<plugin.script.roots>${project.basedir}/src/main/resources</plugin.script.roots>
</systemPropertyVariables>

<!-- other stuff ... -->
</configuration>

<!-- other stuff ... -->
</plugin>
</plugins>
</build>

This way you can donfigure the script roots every time you install the plugin in any instance ...

kind regards,

Thanos 

This widget could not be displayed.

Hi Thanos,

 

that's great, but it still doesn't work :(

I added plugin.script.roots to the pom and tried to run my groovy file from the script console but I got an error FileNotFoundException.

I tried to import the class in the another script but it doesn't work as well. 

This is my pom:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>pl.psi.rmtm.groovy</groupId>
<artifactId>groovyRoot</artifactId>
<version>1.0.0-SNAPSHOT</version>

<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>

<name>groovyRoot</name>
<description>This is the pl.psi.rmtm.groovy:groovyRoot plugin for Atlassian JIRA.</description>
<packaging>atlassian-plugin</packaging>

<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
<!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
<!--
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-annotation</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-runtime</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.onresolve.jira.groovy</groupId>
<artifactId>groovyrunner</artifactId>
<version>2.1.15</version>
<scope>provided</scope>
</dependency>

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

<!-- WIRED TEST RUNNER DEPENDENCIES -->
<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
<version>${plugin.testrunner.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2-atlassian-1</version>
</dependency>

<!-- Uncomment to use TestKit in your project. Details at https://bitbucket.org/atlassian/jira-testkit -->
<!-- You can read more about TestKit at https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Smarter+integration+testing+with+TestKit -->
<!--
<dependency>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-client</artifactId>
<version>${testkit.version}</version>
<scope>test</scope>
</dependency>
-->
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<!-- Uncomment to install TestKit backdoor in JIRA. -->
<!--
<pluginArtifacts>
<pluginArtifact>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-plugin</artifactId>
<version>${testkit.version}</version>
</pluginArtifact>
</pluginArtifacts>
-->
<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>

<systemPropertyVariables>
<plugin.script.roots>${project.basedir}/src/main/resources</plugin.script.roots>
</systemPropertyVariables>


<!-- See here for an explanation of default instructions: -->
<!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>

<!-- Add package to export here -->
<Export-Package>
pl.psi.rmtm.groovy.groovyRoot.api
</Export-Package>

<!-- Add package import here -->
<Import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
*
</Import-Package>

<!-- Ensure plugin is spring powered -->
<Spring-Context>*</Spring-Context>
</instructions>
</configuration>
</plugin>

<plugin>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
<version>1.2.6</version>
<executions>
<execution>
<goals>
<goal>atlassian-spring-scanner</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<scannedDependencies>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
</dependency>
</scannedDependencies>
<verbose>false</verbose>
</configuration>
</plugin>
</plugins>
</build>

<properties>
<jira.version>6.0.1</jira.version>
<amps.version>6.2.4</amps.version>
<plugin.testrunner.version>1.2.3</plugin.testrunner.version>
<atlassian.spring.scanner.version>1.2.6</atlassian.spring.scanner.version>
<!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
<!-- TestKit version 6.x for JIRA 6.x -->
<testkit.version>6.3.11</testkit.version>
<groovy.version>2.2.1</groovy.version>
</properties>

</project>

Hi Weronika, 

If you go to your script console and click the File tab then you will see which are your configured script roots. 

Can you check please ?

Kind regards 

Thanos

This widget could not be displayed.

Hi Thanos,

 

I don't have the file tab in the script console. I am using SR 2.1.15.

script console.PNG

Hi Weronika, 

Judging from the photo and having a second look at your pom I can ee that you use the 2.1.15 version of the ScripRunner. To be honest I am not sure that with this version is possible to do what you want. 

Is it possible to use a 3.* version of the plugin ?

Kind regards, 

Thanos

That was my question at the beginning if it is possible. 

I can't use 3.* version because I am working on JIRA 6.0.1.

Is there any possibility to automate those scripts with the version of SR?

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

576 views 25 15
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you