How to fetch attachment details present in Jira datacenter instance i.e. size, number of attachments present in that particular project, etc.?
Hi,
Do you have Scriptrunner?
Regards,
Jeroen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Had a script for this on the shelf :-). You just need to change the JQL_QUERY variable. Be careful, test on small subset first!
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.AttachmentManager
import com.atlassian.jira.issue.attachment.Attachment
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import org.apache.log4j.Level
import org.apache.log4j.Logger
def log = Logger.getLogger("be.script")
log.setLevel(Level.INFO)
def JQL_QUERY = "<your-JQL>"
AttachmentManager attachManager = ComponentAccessor.getAttachmentManager()
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
JqlQueryParser jqlParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def query = jqlParser.parseQuery(JQL_QUERY)
def queryUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def allIssues = searchService.search(queryUser, query, PagerFilter.getUnlimitedFilter()).getIssues()
long totalSize = 0
long totalAttachs = 0
for (def issue: allIssues) {
List<Attachment> issueAttachs = attachManager.getAttachments(issue)
totalAttachs = totalAttachs + issueAttachs.size()
for(Attachment attachment: issueAttachs) {
totalSize = totalSize + attachment.getFilesize()
}
}
log.info("Total Size => " + totalSize/1024/1024 + " MB")
log.info("Total Attachments => " + totalAttachs)
return "Done!"
Hope this helps!
PS: Mark your question as a Data Center question, not Cloud.
Regards,
Jeroen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.