1

I'm using 0.8 version of Drone-CI tool. I would like to keep only 10 last builds. Is it possible to configure retention policy in the current version? If yes, how can I do it?

Aliaksei Maniuk
  • 1,534
  • 2
  • 18
  • 30

1 Answers1

1

Drone does not have a built-in mechanism for purging or archiving data. With that being said, drone is a relational database which means you can connect and execute queries to purge data.

There is a github issue that includes a sample script to purge data: https://github.com/drone/docs/issues/238

-- delete old logs
DELETE FROM logs WHERE log_job_id IN (
  SELECT proc_id FROM procs WHERE proc_build_id IN (
    SELECT build_id
    FROM repos, builds
    WHERE repo_id = build_repo_id 
    AND build_number < repo_counter - 20
  )
);

-- delete old procs
DELETE FROM procs WHERE proc_build_id IN (
  SELECT build_id
  FROM repos, builds
  WHERE repo_id = build_repo_id 
  AND build_number < repo_counter - 20
);

-- delete old builds
DELETE FROM builds WHERE build_id IN (
  SELECT build_id
  FROM repos, builds
  WHERE repo_id = build_repo_id 
  AND build_number < repo_counter - 20
);

The above script, per the github issue, will likely require modification before it can be used in a production environment. So please test and modify as needed.

Once the script is working to your liking, it can be scheduled with a simple cronjob or with your database management software of choice.

Brad Rydzewski
  • 2,523
  • 14
  • 18