tfs2010 - PowerShell Script to Build TFS Definition -
i trying create ps script create tfs build definition files. found below example. but, it's not working properly. tried follow example , create script without success. in identifying why below script not working appreciated , guidance on how create ps script or example
param( [parameter(mandatory=$true)] [string] $buildname, [string] $servername="http://tfs:80/", [string] $teamproject="myproject" ) # vs 2010 # $tfsclientversion = ", version=10.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a" # vs 2008 $tfsclientversion = ", version=9.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a" [void][system.reflection.assembly]::load("microsoft.teamfoundation.client"+$tfsclientversion) [void][system.reflection.assembly]::load("microsoft.teamfoundation.build.client"+$tfsclientversion) [void][system.reflection.assembly]::load("microsoft.teamfoundation.versioncontrol.client"+$tfsclientversion) $tfs = [microsoft.teamfoundation.client.teamfoundationserverfactory]::getserver($servername) $versioncontrol = $tfs.getservice([microsoft.teamfoundation.versioncontrol.client.versioncontrolserver]) $buildserver = $tfs.getservice([microsoft.teamfoundation.build.client.ibuildserver]) $def = $buildserver.createbuilddefinition($teamproject) $def.name = "$buildname" $def.description = "created powershell script " $agentspec = $buildserver.createbuildagentspec($teamproject) $agentspec.name = "build" $agent = $buildserver.querybuildagents($agentspec).agents[0] $def.defaultbuildagent = $agent $def.defaultdroplocation = "\\build\privatedrops" $def.retentionpolicies.item('failed').numbertokeep = 5 $def.retentionpolicies.item('stopped').numbertokeep = 0 #none $def.retentionpolicies.item('partiallysucceeded').numbertokeep = 5 $def.retentionpolicies.item('succeeded').numbertokeep = 5 $def.save()
you seem try create build definition on tfs 2010 using 2008 assembly , aproach, without provided outputs or errors hard tell exact issue, few thing stand out:
- use version of assemblies match tfs server (as tagged question tfs2010)
- for 2010 suggested way have work api create tfsteamprojectcollection object uri, there use service now.
- your code suggest 2008, there have been major changes how tfs builds work in 2010, specificly defaultbuildagent property obsolete , unused, agents assigned build controller use following reference script.
Comments
Post a Comment