Team Build - an automatically updated agent after it became unavailable

We have a central deployment of Team Foundation Server (2008), where all projects are stored. Each project installs its own build server, on which Team Build runs, to run its own automatic builds.

Here is the problem. When a connection error is detected between TFS and the Team Build server, it transfers the status of the assembly agent to "unavailable", which means that it is unavailable for subsequent assemblies. Our servers have scheduled reboot windows, and when TFS cannot communicate with these agents (or vice versa) during this window, it moves the agent to "inaccessible". Every morning we come and find that we need to manually log in and reactivate the agent.

Is it possible for assembly agents to appear on the network as soon as they reappear? Or perhaps write a script that automatically returns them to the network?

+3
source share
2 answers

I myself saw this problem too - here is a Powershell script that will iterate over all build agents in all Team projects and include them. Please note that the agents will be updated to be included immediately, regardless of whether they are valid (therefore, if the build server is still running when the script is executed - as soon as the assembly triggers - it will return to unavailability)

$serverName = "TFSRTM08"
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.WorkItemTracking.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client")
$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName)
$wit = $tfs.GetService("Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore")
$bld = $tfs.GetService("Microsoft.TeamFoundation.Build.Client.IBuildServer")

$prjs = $wit.Projects
foreach ($proj in $prjs)
{
    $agents = $bld.QueryBuildAgents($proj.Name)
    foreach ($agent in $agents)
    {
        if ($agent.Status -ne "Enabled")
        {
            Write-Output "Enabling Build Agent: " $agent.Name " on Team Project: " $proj.Name " status was " $agent.Status
            $agent.Status = "Enabled"
            $agent.Save()
        }
    }
}
+1
source

TFS2008, AT (15-30 , ), , . - ?

, .NET, , . Windows, , TFS .

, API TFS (Microsoft.TeamFoundation.Build.Client). , IBuildAgent. IBuildServer, , buildAgent.Save().

+2

Source: https://habr.com/ru/post/1711615/


All Articles