I am implementing a fragment with a REST endpoint and I am writing the condition as a script. I need to call a function from another class called Configuration_CreateMultipleSubtasks.groovy.
Here is the structure of my files in the script editor
I need to call a function located in the file Configuration_CreateMultipleSubtasks.groovy. The latter file contains some constant values that I decided to store there.
Here is the code for my condition Fragment_Condition_CreateMultipleSubtasks.groovy. I would like to call the function getSubTaskCreatorHashMap() which is located in another file given that this function stores some constant values.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.plugin.ProjectPermissionKey
import com.atlassian.jira.plugin.webfragment.model.JiraHelper
import CreateMultipleSubtasks.Configuration_CreateMultipleSubtasks
import com.atlassian.jira.project.Project
import org.apache.log4j.Logger
def log = Logger.getLogger("atlassian-jira.log")
Configuration_CreateMultipleSubtasks conf= new Configuration_CreateMultipleSubtasks();
def subTaskCreatorHashMap= conf.getSubTaskCreatorHashMap()
String projectKey1 = subTaskCreatorHashMap["projectKey"] ;
String issueTypeName1 =subTaskCreatorHashMap["issueTypeName"];
String projectKey = "PIE" ;
String issueTypeName ="Defect";
def val=jiraHelper.project?.key==projectKey && issue.issueType.name==issueTypeName
log.warn("MOUNA CONDITION IS TRUE"+ projectKey1+" "+issueTypeName1)
return val
Obviously, my import is not working since I am not able to print projectKey1 and projejctKey2 in the code below.
public class Configuration_CreateMultipleSubtasks {
static def getSubTaskCreatorHashMap(){
def map = [itracCreatemultiplesubtasksIssueTypesId:5,
itracCreatemultiplesubtasksProjectCategoriesID: [10011, 10200, 10220, 10230, 10240, 10670, 10170, 11170, 11270, 11870, 11871, 11872, 11873, 11874, 11875, 12470],
itracCreatemultiplesubtasksProjectCategoriesURL: "http://itrac-sustservice.eur.ad.sag:5555/web/subtaskmgr/Login.jsp?iTrac=:1:&reporter=:2:",
projectKey: "PIE",
issueTypeName: "Defect"]
return map
}
}
This import ...
import CreateMultipleSubtasks.Configuration_CreateMultipleSubtasks
... implies that your class file is stored in a path like <jira-home>/scripts/CreateMultipleSubtasks/Configuration_CreateMultipleSubtasks.groovy
Is that correct?
If not, then adjust the classpath to match the file path.
Also, be sure to define that path in your Jira startup parameter. Read more here
-Dplugin.resource.directories=${JIRA_HOME}/scripts
Also, since you've defined your method as static, there is no need to instantiate.
You can just do this:
def subTaskCreatorHashMap = Configuration_CreateMultipleSubtasks.subTaskCreatorHashMap
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.