TeamCity消息文件夹增长

时间:2014-10-26 12:06:03

标签: teamcity

我的teamcity服务器磁盘空间运行非常低。 主要增长文件夹是“Messages”文件夹,我想知道如何定义清理策略以从messages文件夹中删除旧日志。

目前我的清理规则如下:

History more than 15 days older than the last build and older than the 50th successful build
Artifacts more than 2 days older than the last build and older than the 10th successful build; artifact patterns: +:\\**\\*
Other items are kept forever
Do not prevent dependency artifacts cleanup 

2 个答案:

答案 0 :(得分:3)

如果您运行的是TeamCity 8或更早版本,则存在一个已知问题,即未正确清除messages文件夹,请查看以下链接以获取解决方法(基本上手动删除不再使用的文件):

https://devnet.jetbrains.com/message/5518176#5518176

https://youtrack.jetbrains.com/issue/TW-36830#comment=27-754144

答案 1 :(得分:2)

可能远离最有效的解决方案,但这是我的powershell脚本,它通过Message文件夹并删除所有没有相应消息的索引( .i1)文件( .msg5 )。花一点时间,但是如果你在TC的星期日工作安排它,你不必再担心oweflowing Message文件夹了。使用TeamCity对抗它。

[CmdletBinding()]
param (
    [Parameter()]
    [string]$messageFolder = "G:\TeamCity\Data\system\messages"
)

function HasNoMessage {
    param([System.IO.FileInfo]$indexFile)

    foreach ($message in $messages)
    {
        if ($indexFile.Name.Contains($message.name))
        {
            return $false
        }
    }
    return $true
}

$folders = Get-ChildItem $messageFolder -Recurse | ?{ $_.PSIsContainer }
$count = 0
$totalSize = 0
$preserved = 0

foreach ($folder in $folders)
{
    $table = Get-ChildItem $folder.FullName -include *.i1 -recurse 
    $messages = Get-ChildItem $folder.FullName -include *.msg5 -recurse
    foreach ($index in $table)
    {
        if (HasNoMessage($index))
        {
            $count++
            $totalSize += $index.Length
            remove-item $index.FullName 
        }
        else {$preserved++}
    }
} 
Write-Output("Finished : total files removed : ", $count)
Write-Output("Total size cleaned in MegaBytes : ", ($totalSize / 1MB))
Write-Output("Preserved files : ",  $preserved) 

更新:新的TeamCity版本9.x已经有了这个,所以我强烈建议迁移