TeamBuild: Scheduled build using Team System
Sorry to all the folks who read my blog for C#. This ones about Team System and specifically about the Team Build module :)
Team Build does not have any in-built scheduler and so it does not provide scheduled builds out of the box. However, it does have a command line tool to start team-builds. Any scheduler like the Windows Task Scheduler can be easily setup to use this command line Team Build utility to start builds at predetermined time. The Task Scheduler can be setup using a simple batch file or manually using the Add Scheduled task wizard that comes with Windows.
Where do I setup the scheduler?
Since the scheduler will use the command line TfsBuild.exe utility, you'll need to start the scheduler on either any one of the TFS clients or on a Build Machine.
Doing it through the Scheduled Task Wizard
To open Scheduled Tasks on Windows XP or Windows 2003, click Start, click All Programs, point to Accessories, point to System Tools, click Scheduled Tasks and then Add Scheduled Task. Then choose the TfsBuild.exe (ProgramFiles\Microsoft Visual Studio 8\Common7\IDE\TfsBuild.exe) as the executable and set the schedule and the account information under which you want to run the TfsBuild. At the last page ensure that the "Open advanced properties..." is checked before you hit finish...
In the dialog that opens enter the arguments in the Run text box so that its like...
"d:\Program Files\Microsoft Visual Studio 8\Common7\IDE\TfsBuild.exe" start <TfsServer> <Team Project> <Build Type name>
Doing it through a batch file
I wrote a simple batch file that makes this even easier. Copy/paste the following into a file named schbuild.bat and place it in %ProgramFiles%\Microsoft Visual Studio 8\Common7\IDE and run schbuild.bat to see usage.
@echo off
if "%1" == "" goto Help
if /i "%1" == "-h" goto Help
set server=%1
set project=%2
set buildType=%3
set schedule=%4
set startTime=%5
set startDate=%6
set schName=%2_%3
set tfsCommand="D:\PROGRA~1\MID05A~1\Common7\IDE\TfsBuild.exe start %server% %project% %buildType%"
set user=%userdomain%\%username%
echo %tfsCommand%
schtasks /create /sc %schedule% /tn %schName% /tr %tfsCommand% /st %startTime% /sd %startDate% /ru %user% /rp *
Goto Done
:Help
@echo Usage: schbuild TeamfoundationServer TeamProject BuildType Schedule StartTime StartDate
@echo.
@echo TeamfoundationServer The Team Foundation server.
@echo.
@echo TeamProject Team project name.
@echo.
@echo BuildType Build Type name.
@echo.
@echo Schedule Specifies the schedule frequency.
@echo Valid schedule types: MINUTE, HOURLY,
@echo DAILY, WEEKLY, MONTHLY, ONCE.
@echo.
@echo StartTime Time to start the build in HH:MM:SS
@echo (24 hour format)
@echo.
@echo StartDate Specifies the first date on which the
@echo task runs. The format is mm/dd/yyyy.
:Done
Sample batch file run
To start a nightly build that happens every night at 9:00p.m. use something like
SchBuild.bat MyTfsServer MyTeamProject NightlyBuildType DAILY 21:00:00 11/21/2205
Customizing the Schedule
Once the Team Build has been scheduled through the batch file it can be easily modified using the scheduled tasks user interface. To open Scheduled Tasks use the same steps as mentioned above and then double click on the task named <Team project>_<BuildType> to open it and modify as required.
Comments
- Anonymous
January 11, 2006
Fantastic info Abhinaba. Thanks very much! - Anonymous
February 27, 2006
If you do this on a computer that haven't been connected to the tfs I got an message: "TF20076: The server name Servername provided does not correspond to a server URI that can be found. Confirm that the server name is correct."
Once I connected that machine to the tfs with the team explorer everything was perfect.
Ulrich - Anonymous
February 27, 2006
In case it was never connected to the server try using the full server name as in http://server:8080 - Anonymous
March 24, 2006
Good intro post on Abhinaba's blog about how to schedule builds using Team Build:&nbsp; http://blogs.msdn.com/abhinaba/archive/2005/11/21/495179.aspx... - Anonymous
May 18, 2006
The following link goes to an
excellent article which describes how to create a Team Foundation Server... - Anonymous
June 29, 2006
Hi,I have been googling all over looking out for different ways to create a scheduled build...and trust me...ur blog title just caught my attention..and i kinda thought i could find my solution here..and then voila!!!!!! - Anonymous
August 30, 2006
The comment has been removed - Anonymous
November 11, 2006
Dans un contexte de relation développeur / testeur il est pratique de mettre en place un système de déploiement - Anonymous
December 24, 2006
参阅:http://blogs.msdn.com/abhinaba/archive/2005/11/21/495179.aspx TeamBuild没有内置的日程控制,让Build每日定时发生。... - Anonymous
May 06, 2009
Can any buddy describe me... that how to give the domain and user name i.e. what switch i need to use in command prompt. Currently I am using the following statement: TFSBuild.exe start http://x-tfs.in.abb.com:8080 $y "ITT9-2 1.1" it is saying: TF30063: You are not authorized to access http://x-tfs.in.abb.com:8080.