如何在Drone CI中设置保留策略

时间:2017-10-03 13:25:12

标签: continuous-integration drone drone.io

我正在使用0.8版Drone-CI工具。我想保留最后10个版本。是否可以在当前版本中配置保留策略?如果是,我该怎么做?

1 个答案:

答案 0 :(得分:0)

无人机没有用于清除或存档数据的内置机制。话虽如此,无人机是一个关系数据库,这意味着您可以连接并执行查询以清除数据。

有一个github问题,其中包含一个清除数据的示例脚本: 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
);

根据github问题,上述脚本可能需要修改才能在生产环境中使用。所以请根据需要进行测试和修改。

一旦脚本按照您的喜好工作,就可以使用简单的cronjob或您选择的数据库管理软件进行安排。