This simple script fetches all projects, then fetches each issue in the project. For each issue, it counts the number of attachments and adds it to a running tally for that project.
import com.atlassian.jira.component.ComponentAccessor
def projectManager = ComponentAccessor.getProjectManager()
def projects = projectManager.getProjectObjects()
def issueManager = ComponentAccessor.getIssueManager()
projects.each{ project ->
def attachmentsTotal = 0
def issues = ComponentAccessor.getIssueManager().getIssueIdsForProject(project.id)
issues.each{ issueID ->
def issue = ComponentAccessor.getIssueManager().getIssueObject(issueID)
def attachmentManager = ComponentAccessor.getAttachmentManager().getAttachments(issue).size()
attachmentsTotal += attachmentManager
}
log.warn(project.key + " - " + attachmentsTotal)
}
Leave a Reply