by XDK
5. December 2013 09:37
Solution:
Powershell script to invoke failed Jobs
[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=10.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$configServer = new-object Microsoft.TeamFoundation.Client.TfsConfigurationServer
(new-object System.Uri("http://<Server>:8080/tfs"))
$tfsJobService = $configServer.GetService([Microsoft.TeamFoundation.Framework.Client.
ITeamFoundationJobService])
$jobs= $tfsJobService.QueryJobs()
$jobID = new-object System.Guid("the job ID from deletion of project that failed")
foreach ($job in $jobs)
{
if (($job.JobId -eq $jobID))
{
$FailedJob = $job
$tfsJobService.QueueJobNow($FailedJob,$true)
}
}
Failed Job Ids can be identified using the below query
use [Tfs_Configuration] --check this is the name of the configuration database
Select * FROM [tbl_JobDefinition] where Data like '%failed%'
--Grab the JobId from above and use in JobHistory
select * from [tbl_JobHistory] where JobId='XXX from above query result”
--check the Result and ResultMessage columns