hello,
im trying to make a custom listener via scriptrunner, that will attach the files to the custom mail sending via scriptrunner, that i control my outgoing messages via. But after jira was updated, attachments to the issue arent loaded at the same time as the comment is commited, so the attachment wont become attached - its horrible (and im horribly bad in groovy - im more like good using perl)..
what ive achived so far is this:
import com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.MailAttachment
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.issue.attachment.TemporaryWebAttachment
import com.atlassian.jira.issue.attachment.TemporaryWebAttachmentManager
import webwork.action.ActionContext
def temporaryAttachmentUtil = ComponentAccessor.getComponent(TemporaryWebAttachmentManager)
def formToken = ActionContext.getRequest()?.getParameter(IssueFieldConstants.FORM_TOKEN)
if (formToken) {
def tempWebAttachments = temporaryAttachmentUtil.getTemporaryWebAttachmentsByFormToken(formToken)
tempWebAttachments.each { TemporaryWebAttachment it ->
log.debug "Uploaded attachment name: ${it.filename}"
{MailAttachment a -> ${it.filename}
}
}
but it doesnt compile.. can someone please tip me how to operate this groovy stuff ?
im using jira 7.5.1 and latest scriptrunner aswell - also i have servicedesk and agile - but to be hournest i wish i had nothing...
I think the problem is with
{MailAttachment a -> ${it.filename}
What are you trying to do with the line?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want to send a email then you would need implement something like this
Email email = new Email("dieter@home.at");
email.setFrom(fromStr); email.setSubject("Hello"); email.setMimeType("text/plain"); email.setBody("Body Text"); Multipart multipart = new MimeMultipart("mixed"); MimeBodyPart attachPart = new MimeBodyPart(); String attachFile = "/tmp/SLA_Report.csv"; java.io.File csvFile = new java.io.File("/tmp/SLA_Report.csv"); FileDataSource source = new FileDataSource(csvFile); attachPart.setDataHandler(new DataHandler(source)); attachPart.setFileName(csvFile.getName()); multipart.addBodyPart(attachPart); email.setMultipart(multipart); SingleMailQueueItem item = new SingleMailQueueItem(email); ComponentAccessor.getMailQueue().addItem(item);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
aint that over the top, when using "Send a custom email" under "script listeners" setup..?
Theres a customizable section called "Custom attachment callback" that i try and run the script in.. triggered on all transitions in a certain project that has adds a comment on any issue (then post a mail to the reporter on that comment containing any new attachments, however the build-in option for new attachments via scriptrunner doesnt work anymore, since attachments arent loading in the same transaction as the comment.. (i believe))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
is there really no way to attach the new attachments into a custom email? -the embedded feature doesnt do the job..
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.