I'm developing a JIRA plug-in and have a method which passes a custom Incident object which I populate after parsing input from a mail handler, and then the method creates a JIRA issue based off of those values. Everything works and the issue is created, however, setComponentIds on IssueInputParameters is not actually setting the component IDs I'm passing. The Incident object member componentIds is a Long[] and I've confirmed through debugging that it contains multiple Long values as expected. I've also confirmed that the Components field is on the edit screen for this specific project and that the Component IDs I'm passing are valid for the project I'm creating the issue in. The code is below, any ideas?
public void createIssue(ApplicationUser user, Incident incident) throws CreateException {
JiraAuthenticationContext authContext = ComponentAccessor.getJiraAuthenticationContext();
authContext.setLoggedInUser(ComponentAccessor.getUserManager().getUserByKey(user.getKey()));
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters.setSummary(incident.getTitle())
.setDescription(incident.getAlertMessage())
.setPriorityId(incident.getPriority())
.setComponentIds(incident.getComponentIds())
.setAssigneeId(null)
.setReporterId(incident.getReporter())
.setProjectId(incident.getProjectId())
.setIssueTypeId(incident.getIssueTypeId());
IssueService.CreateValidationResult result = issueService.validateCreate(user, issueInputParameters);
if (result.getErrorCollection().hasAnyErrors()) {
throw new CreateException(result.getErrorCollection().getErrors().toString());
} else {
issueService.create(user, result);
}
}
Component/s wasn't on the Create screen for the project. As soon as I added it, it worked. Would be nice if some sort of notice was thrown in the JIRA logs that the field couldn't be set via the API because it wasn't on the correct screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.