Creating an issue from a plugin
In this recipe, we will see how to programmatically create an issue from a plugin. Prior to Version 4.1, JIRA used IssueManager
to create an issue. From JIRA 4.1, there is this IssueService
class that drives the issue operations. Since IssueService
is recommended over IssueManager
, we will use it in our recipes to create an issue.
How to do it...
The main advantage of using IssueService
over the IssueManager
class is that it takes care of the validation and error handling. The following are the steps to create an issue using the IssueService
class:
Create an instance of the
IssueService
class. You can either inject it in the constructor or get it from theComponentAccessor
class, as shown:IssueService issueService = ComponentAccessor.getIssueService();
Create the issue input parameters. In this step, we will set all the values that are required to create the issue using the
IssueInputParameters
class.a. Create an instance of the
IssueInputParameters
class:IssueInputParameters...