The following script will return the last successful build on a given build definition.
Save the following to a .ps1 file
$project = "testproject"
[URI]$Projecturi = "http://tfsserver:8080/tfs/DefaultCollection/"
function Wait-GetLKGBuild {
[CmdletBinding()]
PARAM (
[Parameter(Mandatory=$true)]
[string]$buildDefinitionName
)
[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.TeamFoundation.Build.Client')
[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.TeamFoundation.Client')
$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($Projecturi)
$buildserver = $tfs.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer])
$rbBuildDefinition = $buildserver.GetBuildDefinition($project, $buildDefinitionName)
$build = $buildserver.GetBuild([Uri]($rbBuildDefinition.LastGoodBuildUri));
New-Object PSObject -Property @{
Buildnumber = $build.BuildNumber;
Requestedfor = $build.RequestedFor;
Status = $build.Status;
CompilationStatus = $build.CompilationStatus;
Start = $build.StartTime;
End = $build.FinishTime;
DropLocation = $build.DropLocation;
SourceGetVersion = $build.SourceGetVersion;
}
}
}
Wait-GetLKGBuild $buildDefinitionName
Friday, April 26, 2013
Subscribe to:
Post Comments (Atom)
Enumerating TFS Permissions for items within the TPC for audit and logging
Below is a powershell cmdlet that I threw together to enumerate data out of our TFS instance. This is used to keep track of permissions in ...
-
The TFS Build Activity logs have lots of useful information. Unfortunately this information is not real easy to get to. Using the TFS 2012...
-
Some teams have found the default bug states don't work well with their teams. Moving to the Active, Resolved, Closed workflow for the ...
Thanks. Great post. Can know the build Agent number also?
ReplyDeletefull detailled article and powershell kit to query tfs build using powershell can be found there : https://freakydinde.wordpress.com/2016/09/14/tfs-powershell/
ReplyDeletePerfect!
ReplyDeleteAny way to additionally query the TestRunStatus? Would be the perfect report:
CompilationStatus: Succeeded
TestRunStatus: Succeeded
etc...
sure,try this : https://freakydinde.wordpress.com/2016/09/14/tfs-powershell
DeleteThanks freaky :)
ReplyDelete