如何清理Allure TestOps中的旧报告数据?
Alright, let's walk through the feasible ways to clean up old report data in Allure TestOps—covering both built-in tools and custom solutions to fit different needs:
This is the safest and most maintainable method, as it's natively supported by Allure TestOps and requires no manual intervention once configured:
- Navigate to the Admin section, then go to Settings > Data Retention
- You can set retention periods for different data types: test reports, launch records, historical test results, etc. For example, set to keep only the last 90 days of reports
- Once configured, the system will automatically run scheduled cleanup jobs to remove expired data, so you don't have to handle it manually
If you need to wipe specific batches of old data (like all reports from a deprecated project), use the UI's bulk delete feature:
- Go to your target project, switch to the Launches tab (since reports are tied to launches)
- Use the filter options to narrow down old entries: filter by creation date, launch status, or test suite
- Check all the launches you want to remove, then click the Delete button at the top of the list
- Important: Export any data you need to keep first—this action is irreversible
For custom cleanup workflows (like deleting only failed old reports or running weekly cleanup jobs), use Allure TestOps' REST API:
- First, generate an API access token from your user profile settings
- Use the
GET /api/launchendpoint to fetch launches matching your criteria (use thecreatedBeforeparameter to target old entries) - Batch-delete the retrieved launches using the
DELETE /api/launch/{id}endpoint - Wrap this logic in a script (Python, Shell, etc.) and set up a cron job or scheduled task to run it automatically
Only consider this if you have deep knowledge of Allure TestOps' database schema and need to remove extremely old data that the above methods can't handle:
- Always back up your entire database first before making any direct changes
- Locate the core tables related to reports and launches:
launch,attachment,test_result, andreport - Write targeted SQL queries to delete old records, e.g.:
DELETE FROM launch WHERE created_date < '2023-01-01'; DELETE FROM attachment WHERE launch_id IN (SELECT id FROM launch WHERE created_date < '2023-01-01'); - After running the queries, restart the Allure TestOps service to sync the application cache with the updated database
Key Notes:
- Backup first, always: No matter which method you choose, never skip backing up critical data before deletion
- Prioritize built-in policies: They're designed to work safely with the platform and avoid unintended data loss
- API automation is great for repeatable, custom cleanup rules that fit your team's workflow
内容的提问来源于stack exchange,提问作者newbie_ABD

