为什么我的工件存储量这么高?我怎样才能摆脱它



我正在尝试获取我的命名空间存储<5GB,但我有一个项目几乎占用了所有空间,因为它的工件存储空间为4.5GB。

我的使用配额屏幕截图

我们设置了管道来运行对GitLab的每次推送,但管道非常简单:安装必要的包并运行测试。我们唯一明确保存的工件是日志文件(如果有的话,通常只有几KB(和失败的浏览器测试的屏幕截图(同样,最多只有几MB(。我们还将工件设置为在24小时后过期。

我们有一个小团队,所以即使在最繁忙的一天,我们也不会有超过15条管道运行,如果每条管道节省5MB(远远超过现实(,那么每天应该是75MB——24小时后应该会减少到0MB。

我最近取消了";保留来自最近成功作业的工件";在设置>使用配额>CI/CD>工件,但它已经检查了一年左右(自从我们开始项目以来(。

我尝试过的其他步骤是进行API调用以删除项目中的所有工件,我编写了一个脚本来获取所有作业ID并删除每个作业ID的所有工件。

有没有可能我们有GB的旧的成功工作工件堵塞了我们的存储?是否可以浏览&手动删除工件?

编辑:这是使用Gitlab.com,而不是自托管。

根据sytech上面的评论,我编写了一个PHP脚本来获取所有管道ID,并删除任何超过1周的管道。这删除了大约3000条旧管道,我的存储配额从大约5GB增加到大约150MB。以下是脚本,以防有人感兴趣:

<?php
/**
* Keep all pipelines 7 days and newer
*/
$cutoffTime = time() - (7 * 24 * 60 * 60);
$ids = [];
$page = 1;
/**
* Get list of all pipeline IDs and store old IDs in array
*/
do {
$response = `curl --header 'PRIVATE-TOKEN: <API_KEY>' 'https://gitlab.com/api/v4/projects/<PROJECT_ID>/pipelines?page=$page&per_page=100' -s`;
$pipelines = json_decode($response);
foreach ($pipelines as $pipeline) {
if (strtotime($pipeline->updated_at) < $cutoffTime) {
$ids[] = $pipeline->id;
}
}
$page++;
} while ($pipelines);
/**
* Delete all pipelines in IDs array
*/
$count = 0;
foreach ($ids as $id) {
echo "Deleting $id ($pipeline->updated_at): ";
$response = `curl --header 'PRIVATE-TOKEN: <API_KEY>' --request 'DELETE' 'https://gitlab.com/api/v4/projects/<PROJECT_ID>/pipelines/$id' -s`;
if (!$response) {
echo "Donen";
$count++;
} else {
echo json_decode($response)->message . "n";
}
}
/**
* Print results
*/
if ($ids) {
echo "nDeleted $count pipelines.nnDone.n";
} else {
echo "nNo pipelines found older than 1 weeknnDone.n";
}

最新更新