console_countAllAttachments_AllJiraDC_issues

PHOTO EMBED

Thu Nov 14 2024 13:22:52 GMT+0000 (Coordinated Universal Time)

Saved by @belleJar #groovy

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)
}
content_copyCOPY

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.