Jira v. 8.2.5
ScriptRunner v. 5.6.1.1-jira8
I am trying to write a script that creates some issues under another issue with Scriptrunner. Specifically this function:
def createIssue(linkMgr, user, parentIssue, issueService, issueType, summary) {
def asUser = parentIssue.getReporter();
log.warn asUser
def issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters
.setProjectId(parentIssue.projectId)
.setIssueTypeId(issueType.id)
.setSummary(summary)
.setReporterId(asUser.key)
def validationResult = issueService.validateCreate(asUser, issueInputParameters)
if (!validationResult.valid) {
log.error validationResult.errorCollection;
return;
}
def result = issueService.create(asUser, validationResult).issue
linkMgr.createIssueLink(parentIssue.getId(), result.getId(), 10219, 1, asUser);
return result;
}
But that's giving me this output:
2020-03-31 19:38:41,652 WARN [runner.AbstractScriptRunner]: edreimiller@aurora.tech(edreimiller)
2020-03-31 19:38:41,667 ERROR [runner.AbstractScriptRunner]: Errors: {reporter=The reporter specified is not a user.}
Error Messages: []
2020-03-31 19:38:41,668 WARN [runner.AbstractScriptRunner]: edreimiller@aurora.tech(edreimiller)
2020-03-31 19:38:41,675 ERROR [runner.AbstractScriptRunner]: Errors: {reporter=The reporter specified is not a user.}
Error Messages: []
I've also tried
def asUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
and grabbing the user outside of the function and passing it in (hence the 'user' in the function arguments).
Right now I am just prototyping this in Script Console, but this will eventually live in the create Transition of the Workflow.