Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Daily report

Thomas.eschenmoser June 30, 2023

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.2023-06-30_11-15-21.jpg

 

How can I do this?

2 answers

2 votes
Alexander Pappert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 30, 2023

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

0 votes
Kseniia Trushnikova
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 2, 2023 edited

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.ComponentAccessor
import java.io.File
import com.atlassian.mail.Email
import com.atlassian.mail.server.MailServerManager
import javax.mail.internet.MimeBodyPart
import javax.mail.internet.MimeMultipart
import javax.activation.FileDataSource
import javax.activation.DataHandler

//Define mail settings
def 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 located
def 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 header
file.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.")
}

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, ace, atlassian community event, donation, girls who code, women in tech, malala fund, plan international, kudos, community badge, badge, atlassian badge, International Women’s month, International Women’s Day, women's month, women's day

10 for Change at Atlassian Community Events

Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!

Join an Atlassian Community Event!
AUG Leaders

Upcoming Jira Events