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.ComponentAccessor
import 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!
Something like this:
Issues.search('status = Done AND updated <= -90d').each { issue ->
// delete attachments
def 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OK, let me be more precise. The script will not delete the issues.
But, if an issue has an attachment "A" 10 years old, and another "B" 2 days old, then the issue was updated 2 days ago and nothing will be deleted. If I understand you correctly, "A" should be deleted in this case.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
yes I think you can, but you have to script...
Find issue and parse result for find attachment and loop on it
https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/issue-getIssue
https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/attachment-removeAttachment
Best Regards
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.