0

我有一个非常繁忙的构建服务器。在美好的一天,我们创建了近 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();
    }
}
4

1 回答 1

1

API 中没有用于此的端点。如果您确实决定您很乐意使用仪表板用于手动清理的相同 HTTP POST,那么在我看来,这很简单:

curl -d "cleanupPageAction=startCleanup" \
    http://user:password@builds.company.com/admin/cleanupPolicies.html
于 2015-05-06T06:49:13.867 回答