Last active
September 16, 2016 04:06
-
-
Save ryanvgates/446f6059efd52ee44859 to your computer and use it in GitHub Desktop.
TFS PSM
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
# | |
# TFS.psm1 | |
# | |
Function QueueBuilds { | |
param($serverName, $teamProject, [string[]]$buildDefinitionNames) | |
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client") | |
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client") | |
$serverName=$serverName | |
$teamProject=$teamProject | |
$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName) | |
$buildserver = $tfs.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer]) | |
foreach($buildDefinitionName in $buildDefinitionNames) { | |
Write-Output "Queuing build $buildDefinitionName" | |
$buildDefinition = $buildserver.GetBuildDefinition($teamProject, $buildDefinitionName) | |
$buildRequest = $buildDefinition.CreateBuildRequest(); | |
Write-Output $buildRequest | |
$result = $buildserver.QueueBuild($BuildReq) | |
} | |
} | |
Export-ModuleMember -Function 'QueueBuilds' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is still broken. Use this:
Function QueueBuilds {
param($serverName, $teamProject, [string[]]$buildDefinitionNames)
}
Export-ModuleMember -Function 'QueueBuilds'
Works a lot better. You got us 90% of the way there and thanks but please test your code. I'm not a Powershell guy.