Author Posts

February 12, 2016 at 2:55 am

I am trying to retrieve queued builds from TFS Server using the IBuildServer Interface. However I am not able to retrieve queued builds on specific agents for a given controller. That is required because if there is a build in progress the Cache Deletion should not happen.

$tfsservername = 'TFS LINK'

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")  
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client")  
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Common") 
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.WorkItemTracking.Client")

$server = new-object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(New-Object Uri($tfsservername)) 
# creating TFSServer Instance
$buildServer = $server.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer]) 


$spec = $buildServer.CreateBuildQueueSpec('*','*')
$build = $buildServer.QueryQueuedBuilds($spec).QueuedBuilds

I tried searching for methods of IBuildServer but there is no method that links Agents and Queued Builds.

I want to use IQueuedBuild Interface here but i don't know how to use it.

Any suggestions how can i find Queued builds on an specific agent ?