Last active
November 30, 2015 14:19
-
-
Save mercdev/98a6908fd144032f8ef6 to your computer and use it in GitHub Desktop.
Queue all enabled builds in TFS via PowerShell
This file contains hidden or 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
cls | |
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client") | |
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client") | |
$serverName = "http://server.fqdn:8080/tfs" | |
$teamProject = "project_name" | |
$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName) | |
$buildserver = $tfs.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer]) | |
$buildDefinitions = $buildServer.QueryBuildDefinitions($teamProject).Name | |
$buildDefinitions = $buildDefinitions | Sort | |
foreach($buildDefinitionName in $buildDefinitions) | |
{ | |
$buildDefinition = $buildserver.GetBuildDefinition($teamProject, $buildDefinitionName) | |
if ($buildDefinition.Enabled) | |
{ | |
#if ($buildDefinitionName.Contains("(D") -or $buildDefinitionName.Contains("(T")) | |
#{ | |
Write-Output "Queuing build -> $buildDefinitionName" | |
$buildRequest = $buildDefinition.CreateBuildRequest(); | |
$result = $buildserver.QueueBuild($buildRequest) | |
#} | |
} | |
else | |
{ | |
Write-Output "$buildDefinitionName is disabled, skipping." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment