I'm trying to set up a groovy service in JIRA to read a CSV file and create tickets based on values in that. When I run the script manually through the script console, it works as expected. When I set up the service, it doesn't create the tickets and gives the below error.
Error creating issue at 1: Errors: {pid=Anonymous users do not have permission to create issues in this project. Please try logging in first.}
Error Messages: []
My guess is that running this from the script console uses the currently user logged in (myself) which it can't reference while running as a service. This would be why it works from the script console and not as a service.
Below is the snippet of code that is actually doing the creation. While I didn't include it in the code block, assume that issueInput object is a valid IssueInputParameters. If there is anything relevant that is missing from the snippet of code that would be helpful for troubleshooting, let me know and I can fill in any blanks. I figured the entire script might not be necessary since it works just fine from the script console.
ApplicationUser user = ComponentAccessor.UserManager.getUserByName("admin")
IssueService.CreateValidationResult createValidationResult = issueService.validateCreate(user, issueInput)
if (createValidationResult.isValid()) {
IssueService.IssueResult issueResult = issueService.create(user, createValidationResult)
} else {
log.error("Error creating issue at " + rowCount + ": " + createValidationResult.getErrorCollection())
}Based on the requirements I have, it is not an acceptable solution to allow anyone to create issues in the project.
What changes needs to be made, either to the script or otherwise, to allow this service to create issues in the project?