Welcome to MSDN Blogs Sign in | Join | Help

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.

Published Monday, November 21, 2005 1:50 PM by abhinaba
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: TeamBuild: Scheduled build using Team System

Wednesday, January 11, 2006 4:24 PM by Earl Damron
Fantastic info Abhinaba. Thanks very much!

# re: TeamBuild: Scheduled build using Team System

Tuesday, February 28, 2006 3:03 AM by Ulrich Freiermuth
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

# re: TeamBuild: Scheduled build using Team System

Tuesday, February 28, 2006 4:49 AM by abhinaba
In case it was never connected to the server try using the full server name as in http://server:8080

# VSTS Tip: Build Scheduling

Friday, March 24, 2006 7:24 PM by Eric Jarvi
Good intro post on Abhinaba's blog about how to schedule builds using Team Build:&amp;nbsp; http://blogs.msdn.com/abhinaba/archive/2005/11/21/495179.aspx...

# Automating Build Processes with Team Foundation Server

Thursday, May 18, 2006 9:12 AM by Technical Weblog of Eric Charran

The following link goes to an
excellent article which describes how to create a Team Foundation Server...

# re: TeamBuild: Scheduled build using Team System

Thursday, June 29, 2006 8:55 AM by sindhu
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!!!!!!

# re: TeamBuild: Scheduled build using Team System

Thursday, August 31, 2006 7:48 AM by does not run
the scheduler say could not start

I double checked the project name, server name and build type  here the command


C:\Program Files\Microsoft Visual Studio 8\Common7\IDE>schbuild rsktech-virtual
practice buildUnitTest DAILY 12:38:00 31/08/2006


the date format in USA version is not accepted as my machine is in UK

# Automatiser la publication de sites Web

Saturday, November 11, 2006 7:11 PM by Azra [Florent Santin]

Dans un contexte de relation développeur / testeur il est pratique de mettre en place un système de déploiement

# 配置Team Build的每日构建

Sunday, December 24, 2006 1:15 PM by 浅水滩

参阅:http://blogs.msdn.com/abhinaba/archive/2005/11/21/495179.aspx TeamBuild没有内置的日程控制,让Build每日定时发生。...

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker