Commit 3191638a authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

cleanup of tags except the latest

parent 6b945213
Pipeline #4015 passed with stage
in 43 seconds
......@@ -16,13 +16,35 @@ foreach ($projects as $index => $project) {
foreach ($registries as $index => $registry) {
$branch = getBranch($registry["project_id"], $registry["name"]);
if (empty($branch)) {
// Branch existiert nicht
print("\t[" . ($index + 1) . "/" . sizeof($registries) . "] Branch " . $registry["name"] . " existiert nicht! Removing registry entry... ");
deleteRegistryEntry($project["id"], $registry["id"]);
print(PHP_EOL);
} else {
print("\t[" . ($index + 1) . "/" . sizeof($registries) . "] Branch " . $registry["name"] . " existiert! Removing all tags but the latest... ");
deleteRegistryTags($project["id"], $registry["id"]);
print(PHP_EOL);
}
}
}
function deleteRegistryTags($projectId, $registryId)
{
global $token, $gitlab_url;
$url = $gitlab_url . "/api/v4/projects/$projectId/registry/repositories/$registryId/tags?private_token=$token&keep_n=1&name_regex=.*";
$ch = curl_init();
try {
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
print($httpCode);
} finally {
curl_close($ch);
}
}
function deleteRegistryEntry($projectId, $registryId)
{
global $token, $gitlab_url;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment