How to use automation rules in Jira to delete attachments from old issues
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
The purpose of this article is to explain how to setup an automation to remove all attachments from work items that weren't updated during a time frame you set as a deadline in your projects.
Solution
Before you delete attachments
Deleted Attachments are gone forever
Note that once you remove the attachments, there is no backup file or anything you can do to retrieve them. They will be completely deleted.
Consider getting a copy of all attachments using export attachments via the REST API, and use a more restrictive JQL query initially.
Automation Rule Setup
Access your Jira environment and go to Settings (⚙) > System > Global Automation.
Choose Create rule to create the automation rule with the following options:
As the Trigger, choose the Scheduled option.
Choose the frequency and the time zone for the execution. See Trigger: Scheduled for more details
Set the JQL query to filter all work items for which the attachments should be removed.
For example, to select all work items that haven't changed in the last week, use
attachments is not empty and updated < startOfDay("-7d")
Adjust the query to fit your requirements.
Choose the ACTION in this case, Delete Attachments. In the drop-down, select All attachments.
Select Turn on rule and give the rule a name to enable the rule.
✔️ Now it's done.
Executing the rule
Wait for the scheduled run time, and the attachments will be deleted based on the given JQL.
OR use the option Run Rule to run the rule immediately.
Was this helpful?