Created
June 8, 2012 14:51
-
-
Save adamskt/2896008 to your computer and use it in GitHub Desktop.
A function to get the latest TFS 2010 successful build drop location for a given project and definition.
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
function Get-LatestDropLocation { | |
param( | |
[Parameter(Position=0,Mandatory=$true)] [string]$tfsLocation, | |
[Parameter(Position=1,Mandatory=$true)] [string]$projectName, | |
[Parameter(Position=3,Mandatory=$true)] [string]$buildDefinitionName | |
) | |
Add-Type -AssemblyName "Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" | |
Add-Type -AssemblyName "Microsoft.TeamFoundation.Build.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" | |
$tfsUri = New-object Uri($tfsLocation) | |
$teamProjectCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfsUri) | |
$service = $teamProjectCollection.GetService([Type]"Microsoft.TeamFoundation.Build.Client.IBuildServer") | |
$spec = $service.CreateBuildDetailSpec($projectName, $buildDefinitionName) | |
$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) { Write-Output $results.Builds[0].DropLocation } else { Write-Error "No builds found." } | |
} | |
Get-LatestDropLocation "http://tfs.mydomain.local:8080/defaultcollection" "MyProject" "MyBuildDefinition" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment