In this recipe, we will see how to create an issue from a plugin programmatically. We will be using IssueService
to take advantage of its validation and error handling capabilities.
Following are the steps to create an issue using the IssueService
:
Create an instance of the
IssueService
class. You can either inject it in the constructor, or get it from theComponentAccessor
, 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 issueInputParameters = issueService.newIssueInputParameters();
b. Populate the
IssueInputParameters
with the values required to create the issue, as shown in the next few lines of code:issueInputParameters .setProjectId...