Last active
October 5, 2015 22:58
-
-
Save adamskt/2891859 to your computer and use it in GitHub Desktop.
A way to get the latest successful drop location from a TFS build.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -AssemblyName "Microsoft.TeamFoundation.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" | |
Add-Type -AssemblyName "Microsoft.TeamFoundation.Build.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" | |
$tfsUri = New-object Uri("[[http://your.tfs.server:8080/defaultcollection]]") | |
$teamProjectCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfsUri) | |
$service = $teamProjectCollection.GetService([Type]"Microsoft.TeamFoundation.Build.Client.IBuildServer") | |
$spec = $service.CreateBuildDetailSpec("[[Your Project Name]]", "[[ Your build definition name]]") | |
$spec.MaxBuildsPerDefinition = 1 | |
$spec.QueryOrder = [Microsoft.TeamFoundation.Build.Client.BuildQueryOrder]::FinishTimeDescending | |
$spec.Status = [Microsoft.TeamFoundation.Build.Client.BuildStatus]::Succeeded | |
$results = $service.QueryBuilds($spec) | |
if ($results.Builds.Length -eq 1) { $results.Builds[0].DropLocation } else { Write-Error "No builds found." } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should work with TFS2010, just change the Add-Type references.