Creating a Script Plugin for JIRA 6

Wero July 20, 2017

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

0 votes
Wero August 2, 2017

Hi Thanos,

 

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

script console.PNG

Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 2, 2017

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

Wero August 2, 2017

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?

0 votes
Wero August 2, 2017

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>
Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 2, 2017

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

0 votes
Wero August 1, 2017

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

Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 1, 2017

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 

0 votes
Wero July 24, 2017

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

Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 24, 2017

Hi Wero, 

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

regrads, Thanos

0 votes
Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 21, 2017

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

Suggest an answer

Log in or Sign up to answer