I have a centos7 server, the attachments directory has become large, how can I automatically delete attachments that are older than n days? Perhaps there is a template ?
Hello @Kirill
If you are on Data Center, Automation for Jira has the ability to do this with a Scheduled job. You can have the job run a JQL like
status = Done AND updated <= -90d
Then have the job delete all attachments.
If you are on server (just a reminder server goes out of support in 1 year) I'd recommend taking a look at Script Runner for Jira. There is a built-in script that does exactly what you want. You can also write a scripted job that does the above.
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.AttachmentManagerAttachmentManager attachmentManager = ComponentAccessor.getAttachmentManager()def attachments = issue.get("attachment");attachments.each { attachment -> attachmentManager.deleteAttachment(attachment)}
If you have any further questions feel free to reach out. Thanks!
I didn't understand how to make this script delete attachments older than n days?
Something like this:
Issues.search('status = Done AND updated <= -90d').each { issue ->// delete attachmentsdef attachments = issue.get("attachment");attachments.each { attachment -> attachmentManager.deleteAttachment(attachment)}
https://library.adaptavist.com/entity/jql-search
You can also take a look at the
com.atlassian.jira.bc.issue.search.SearchService
as well as another way to execute JQL.
https://docs.atlassian.com/software/jira/docs/api/8.1.0/com/atlassian/jira/bc/issue/search/SearchService.html
Well, this script will find the issues that were not updated for 90 days and delete all their attachments. It may not be exactly what you wanted, beware!
It looks like you're new here. Sign in or register to get started.