Hello,
I'm trying to clone attachments from issue to newIssue with this function.
I'm in Jira 6.2
But I receive an error.
Function
CopyAttach = { Issue issue, MutableIssue newIssue ->
attachmentManager = componentManager.getAttachmentManager()
pathManager = componentManager.getAttachmentPathManager()
attachmentManager.getAttachments(issue).each {attachment ->
filePath = PathUtils.joinPaths(pathManager.attachmentPath, issue.projectObject.key, issue.key, attachment.id.toString())
log.debug("*** CopyIssue :: filePath = $filePath")
atFile = new File(filePath)
log.debug("*** CopyIssue :: New : OK")
if (atFile.exists()) {
try {
if (atFile.canRead()) {
log.debug("*** CopyIssue :: read : OK")
CreateAttachmentParamsBean bean = new CreateAttachmentParamsBean(atFile,attachment.filename,attachment.mimetype, attachment.author, newIssue , false , false, null, attachment.created, true)
attachmentManager.createAttachment(bean)
log.debug("*** CopyIssue :: attachment : OK")
}
}
catch (SecurityException se) {
log.debug("*** CopyIssue :: Could not read attachment file. Not copying. (${se.message})")
}
}
else {
log.debug("*** CopyIssue :: Attachment file does not exist where it should. Not copying.")
}
}
}
Error
2014-07-07 17:13:03,842 http-bio-8080-exec-19 ERROR FAB055 1033x8965x1 1y2tkcp 172.24.21.108 /secure/CommentAssignIssue.jspa [onresolve.jira.groovy.GroovyRunner] The script failed : javax.script.ScriptException: javax.script.ScriptException: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.atlassian.jira.issue.attachment.CreateAttachmentParamsBean(java.io.File, java.lang.String, java.lang.String, java.lang.String, com.atlassian.jira.issue.IssueImpl, java.lang.Boolean, java.lang.Boolean, java.util.LinkedHashMap, java.sql.Timestamp, java.lang.Boolean)
2014-07-07 17:13:03,842 http-bio-8080-exec-19 ERROR FAB055 1033x8965x1 1y2tkcp 172.24.21.108 /secure/CommentAssignIssue.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Script post-function failed on DMI-8882: \\jira\Jira\AppData\Scripts\CopyIssue.groovy
javax.script.ScriptException: javax.script.ScriptException: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.atlassian.jira.issue.attachment.CreateAttachmentParamsBean(java.io.File, java.lang.String, java.lang.String, java.lang.String, com.atlassian.jira.issue.IssueImpl, java.lang.Boolean, java.lang.Boolean, java.util.LinkedHashMap, java.sql.Timestamp, java.lang.Boolean)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:117)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:103)
at javax.script.AbstractScriptEngine.eval(Unknown Source)
at com.onresolve.jira.groovy.GroovyRunner.runFile(GroovyRunner.java:102)
at com.onresolve.jira.groovy.GroovyRunner.run(GroovyRunner.java:62)
at com.onresolve.jira.groovy.GroovyFunctionPlugin.execute(GroovyFunctionPlugin.java:38)
at com.opensymphony.workflow.AbstractWorkflow.executeFunction(AbstractWorkflow.java:1050)
at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1446)
at com.opensymphony.workflow.AbstractWorkflow.doAction(AbstractWorkflow.java:564)
at com.atlassian.jira.workflow.OSWorkflowManager.doWorkflowActionInsideTxn(OSWorkflowManager.java:957)
at com.atlassian.jira.workflow.OSWorkflowManager.doWorkflowAction(OSWorkflowManager.java:912)
at com.atlassian.jira.bc.issue.DefaultIssueService.transition(DefaultIssueService.java:450)
What is missing ?
Thx
In the constructor of CreateAttachmentParamsBean you are using attachment.author to get the user. That method returns the user name as String, but the constructor expects an ApplicationUser. Use attachment.authorObject instead.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.