[英]Why is my artifact storage so high? How can I get rid of it?
I am trying to get my namespace storage <5GB, but I have one project that is using up almost all of the space because it's artifact storage is 4.5GB.我试图让我的命名空间存储 <5GB,但我有一个项目几乎用完了所有空间,因为它的工件存储是 4.5GB。
Screenshot of my usage quota我的使用配额截图
We have pipelines set to run every push to GitLab, but the pipelines are quite simple: install necessary packages and run tests.我们设置了管道来运行每次推送到 GitLab,但管道非常简单:安装必要的包并运行测试。 The only artifacts we explicitly save are log files (usually only a few KB, if anything), and screenshots of failed browser tests (again, a couple of MB at most).
我们明确保存的唯一工件是日志文件(通常只有几 KB,如果有的话)和失败的浏览器测试的屏幕截图(同样,最多几 MB)。 We also have artifacts set to expire after 24 hours.
我们还将工件设置为在 24 小时后过期。
We have a small team, so even on our busiest day, we won't have more than 15 pipelines run, and if each pipeline saves 5MB (way more than reality), it should be 75MB a day -- which should expire down to 0 MB after 24 hours.我们有一个小团队,所以即使在我们最忙碌的一天,我们运行的管道也不会超过 15 个,如果每个管道节省 5MB(比实际多),那么每天应该是 75MB——到期时间应该是24 小时后为 0 MB。
I recently unchecked "Keep artifacts from most recent successful jobs" in Settings > Usage Quotas > CI/CD > Artifacts but it had been checked for a year or so (since we started the project).我最近在“设置”>“使用配额”>“CI/CD”>“工件”中取消选中“保留来自最近成功工作的工件”,但它已经检查了一年左右(自从我们开始项目以来)。
Other steps I've tried is making API calls to delete all artifacts in the project and I wrote a script to get all job IDs and delete all artifacts for each job ID .我尝试过的其他步骤是进行 API 调用以删除项目中的所有工件,我编写了一个脚本来获取所有作业 ID并删除每个作业 ID 的所有工件。
Is it possible that we have GB of old successful job artifacts clogging up our storage?我们是否有可能有 GB 的旧成功作业工件堵塞了我们的存储空间? Is it possible to browse & delete artifacts manually?
是否可以手动浏览和删除工件?
Edit: this is using Gitlab.com, not self-hosted.编辑:这是使用 Gitlab.com,不是自托管的。
As per sytech's comment above , I wrote a PHP script to get all pipeline IDs and delete any pipelines that are older than 1 week. 根据上面 sytech 的评论,我编写了一个 PHP 脚本来获取所有管道 ID 并删除任何超过 1 周的管道。 This removed around 3000 old pipelines, and my storage quota went from from ~5GB to ~150MB.
这删除了大约 3000 个旧管道,我的存储配额从 ~5GB 变为 ~150MB。 Here's the script in case anyone is interested:
如果有人感兴趣,这是脚本:
<?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 "Done\n";
$count++;
} else {
echo json_decode($response)->message . "\n";
}
}
/**
* Print results
*/
if ($ids) {
echo "\nDeleted $count pipelines.\n\nDone.\n";
} else {
echo "\nNo pipelines found older than 1 week\n\nDone.\n";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.