Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scheduled Job to List issues which have comments of certain size

Uday Kiran Raparthy August 1, 2022

Is it possible to have a cron job with SQL Query which will list issues and comment details if it exceeds certain size? This Job with SQL Query should also notify via email to keep a watch if any new comments are created

1 answer

1 accepted

1 vote
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
August 19, 2022

Hi @Uday Kiran Raparthy

Just to check, why do you want to use the SQL query to get the issues and comments? This can be done by doing a basic iteration of the issues list. For example:-

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.project.Project

def commentManager = ComponentAccessor.commentManager
def projectManager = ComponentAccessor.projectManager
def issueManager = ComponentAccessor.issueManager

def comments = [] as ArrayList<Comment>

projectManager.projectObjects.each { Project project ->
def issues = issueManager.getIssueIdsForProject(project.id)
issueManager.getIssueObjects(issues).each {
comments.addAll(commentManager.getComments(it))
}
}

comments.each {
if (it.body.length() > 50) {
log.warn "====>>> Comment Length Exceeded"
}

}

null

Please note that this sample code is not 100% exact to your environment. Hence, you will need to make the required modifications.

Also, the null is added at the end of the code to clear up any values and to avoid the error message from the Scheduled Job.

I hope this helps to solve your question. :)

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer