Starting with version 2.3.7 of Project Configurator, it is possible to use the app services from a Groovy script inScript Runner for Jira (SR4J)or from any Java program (another app, for example) running within the Jira instance.
Project Configurator must be installed and licensed in your instance.
Once your code has been compiled, if you want to test it, it is necessary to have Project Configurator—version 2.3.7 or higher—installed and licensed in your development instance. Project Configurator jar files can be downloaded from theMarketplace.
Whether you are driving Project Configurator from a Groovy script or a Java class, you will need the Javadoc for understanding what classes, methods, etc., are available. The Javadoc jar files for each version of the API are published at our External Maven repository.
From Project Configurator version 3.3.1, the methodgetExportedFilefrom the interfaceExportResultis deprecated. The methodgetExportedReturnFileshould be used instead. This new method returns the export configuration file directly, so it is no longer necessary to write the XML string to a file. See ourJavaandGroovyexamples.
Using Project Configurator from a Groovy script in ScriptRunner for Jira
To use Project Configurator’s services, you need to get an instance of the interface that provides the required operation:
ProjectConfigExporter, ProjectConfigImporter, ProjectCompleteImporter or ProjectCompleteExporter
In the examples below, those instances have been retrieved using a call toComponentAccessor.getOSGiComponentInstanceOfType(…)
Project Configurator is able to run most operations in two modes: asynchronous and synchronous.
Methods that run in synchronous mode are explicitly marked in their name (likeexportSynchronous(…)).
On the other hand, methods that run asynchronously do not have any special name (likeexport(…)).
Using Project Configurator from Java
Using Project Configurator from Java code (i.e., another app) has some extra requirements relative to usage from a Groovy script in SR4J. These specific requirements are described below.
It is also useful to look at the previous section with Groovy script examples, as those examples have been created with a coding style that is highly compatible with Java.
Add dependency in the pom.xml
First of all, you need to declare in your pom.xml file that your code depends on this API. This only requires adding this dependency to the xml:
As mentioned for the Groovy scripts, you will need to get the component objects that implement the API. This can be done in a variety of ways.
Declare the imported components in atlassian-plugin.xml
If your app is not using the Atlassian Spring Scanner, you must declare in its atlassian-plugin.xml file that it will import the components you need to run exports, imports, or other operations. For example, if you want to export configurations or obtain the graph of dependencies for configuration objects, you would need to add this line:
In this case, you can inject the required dependencies to the API objects without the need to add an explicit component import declaration in atlassian-plugin.xml. Using the correct annotations will be enough: