Creating an issue from a plugin
In this recipe, we will see how to create an issue from a plugin programmatically. We will be using IssueServiceto take advantage of its validation and error handling capabilities.
How to do it...
Following are the steps to create an issue using the IssueService:
Create an instance of the
IssueServiceclass. 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
IssueInputParametersclass:a. Create an instance of the
IssueInputParametersclass:IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
b. Populate the
IssueInputParameterswith the values required to create the issue, as shown in the next few lines of code:issueInputParameters .setProjectId...