我有一个非常繁忙的构建服务器。在美好的一天,我们创建了近 200GB 的工件。清理策略可以每天运行一次,这对我的情况来说是不够的。我搜索了 teamcity 文档,发现零个 API 端点来支持手动清除触发器。
是否可以从脚本/程序手动触发清理?如何做到这一点?
在最坏的情况下,我可以调整并追踪当我手动强制清理时会发生什么,但它的道路很混乱,我不想继续下去。
这里也是 C# 版本
void Main()
{
var cookieContainer = new CookieContainer();
var baseAddress = new Uri("http://teamcity");
var contentDictionary = new Dictionary<string,string>();
contentDictionary["cleanupPageAction"]= "startCleanup";
using (var handler = new HttpClientHandler() { CookieContainer = cookieContainer,
Credentials = new NetworkCredential("user","password","domain")})
using (var client = new HttpClient(handler) { BaseAddress = baseAddress })
{
var content = new FormUrlEncodedContent(contentDictionary);
var result = client.PostAsync("/admin/cleanupPolicies.html", content).Result;
result.EnsureSuccessStatusCode();
}
}