I have a Project where I would like to have an automated daily report at midnight.
It should create an excel file or csv file with the subject and the custom field 'auftrag'.
See attached screenshot.
How can I do this?
you could create an issue search and use the subscription to send it daily
but this will be a mail with the jira format, no excel, but you can copy it into excel
Hi Thomas,
You can do this with apps like JMWE or Scriptrunner. Here's the example how to create a CSV file and send it via email:
import com.atlassian.jira.component.ComponentAccessorimport java.io.Fileimport com.atlassian.mail.Emailimport com.atlassian.mail.server.MailServerManagerimport javax.mail.internet.MimeBodyPartimport javax.mail.internet.MimeMultipartimport javax.activation.FileDataSourceimport javax.activation.DataHandler//Define mail settingsdef mailServerManager = ComponentAccessor.getComponent(MailServerManager)def recipient = "example@example.com"def subject = "Email Subject"def body = "This is the example email."//Define where the file will be locateddef file = new File('/home/jira/jira-data/export/report.csv')def fileSource = new FileDataSource(new File('/home/jira/jira-data/export/report.csv'))//Define JQL//def issues = jqlSearch("jql", MAX_RESULTS)def issues = jqlSearch("project = 'Production Findings' AND Auftrag is not EMPTY", 1000)//Define CSV headerfile.write("Issue Key,Summary,Auftrag")file.append("\n")for (issue in issues) { def key = issue.get('issuekey') def summary = issue.get('summary') def auftrag = issue.get('Auftrag') file.append("$key,$summary,$auftrag") file.append("\n")}if (fileSource) { def multipart = new MimeMultipart() def textPart = new MimeBodyPart() textPart.setText(body) multipart.addBodyPart(textPart) def attachmentPart = new MimeBodyPart() attachmentPart.setDataHandler(new DataHandler(fileSource)) attachmentPart.setFileName(fileSource.getName()) multipart.addBodyPart(attachmentPart) def email = new Email(recipient) def mailServer = mailServerManager.defaultSMTPMailServer email.setSubject(subject) email.setMultipart(multipart) def threadClassLoader = Thread.currentThread().contextClassLoader Thread.currentThread().contextClassLoader = mailServer.class.classLoader mailServer.send(email) Thread.currentThread().contextClassLoader = threadClassLoader}else { log.error("The file is not found.")}
It looks like you're new here. Sign in or register to get started.