Hi
I have added post function script, it is showing error "
com.atlassian.jira.web.util.AttachmentException: Got error while saving attachment Testing.txt: Got exception while saving attachment in attachment store. Exception: C:/Users/kbharadwaj/Downloads/Testing.txt (No such file or directory)
Here is my code :
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.attachment.CreateAttachmentParamsBean
def attachmentManager = ComponentAccessor.getAttachmentManager()
def user = ComponentAccessor.getJiraAuthenticationContext()?.loggedInUser
String pathToFile = "C:/Users/kbharadwaj/Downloads/"
String fileName = "Testing.txt"
String pathAndFile = pathToFile+fileName
def bean = new CreateAttachmentParamsBean.Builder()
.file(new File(pathAndFile))
.filename(fileName)
.contentType("text/txt")
.author(user)
.issue(issue)
.copySourceFile(true)//you must do this otherwise it deletes the source file from the file system
.build()
attachmentManager.createAttachment(bean)