I have a groovy script and in it I create issues several times under different conditions. I have copied pasted the below code several times in my script. I want to write a function to do that. But when i write these lines in a function, nothing is accessible. The issueFactory, the functions of MutableIssue, nothing. They give an error. Why is that?!
MutableIssue newSubTask = issueFactory.getIssue()
newSubTask.setAssigneeId(user.name)
newSubTask.setParentObject(parentIssue)
newSubTask.setFixVersions(Arrays.asList(versionn))
newSubTask.setProjectObject(parentIssue.getProjectObject())
newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{it.getName() == "Sub-task"}.id)
...
..