Automated Nightly Build System
by Michael Perry · 04/03/2007 (11:25 am) · 1 comments
Download Code File
Common Info:
This tutorial is based on a standard Windows XP/NT operating system, with all programs installed to the default path. Any paths or directories I refer to can be changed to suit your folder hierarchies.
This is an add-on to my previous resource, Step by Step source control setup, so you can refer to that for information not described here.
You will be manipulating Windows environment variables, using automated batch programs, and setting up a Windows Scheduled Tasks.
Programs you need:
Microsoft Visual Studio (this tutorial is using 2005 express)
Subversion (this tutorial is using version 1.3.2)
Command Line Information:
How to open:
1. Start
2. Run
3. Type cmd
4. Press enter
5. cd c: (this just gets you to the root C:\ drive)
Variables Used:
svn - This is a variable containing the path to C:\Program Files\Subversion\bin\svn.exe
%VS80COMNTOOLS% - This is an environment variable that contains the path to Microsoft's Visual Studio tools. Both the tools and the variable are automatically set up for you.
Commands used:
svn checkout - Will perform a full checkout, using a specified address to a repository and checkout directory
svn update - Updates an existing directory containing svn files
cd - Changes directories
xcopy - Copies a folder and all its subdirectories
call - Invokes another batch file
devenv - Invokes developer environment command, used for compiling code without opening Visual Studio.
What to change in the included batch files:
(modify batch files by right clicking them, then left clicking on edit)
1. Change any file paths or directories to match your folder hierarchy, if different from mine.
2. Modify the following line in SVNCheckout.bat:
Setup:
1. Create a folder, C:\nightlyBuild, and check out the current repository you are working from to here.
2. Open the command prompt and test the following command:
3. If you are asked for parameters, skip steps 4-7. If svn is an unknown command, go to step 4.
4. Go to : Start->Settings->Control Panel->System->Advanced->Environment Variables
5. Click New under "System Variables"
6.
8. Copy the batch files from this resource to C:\
9. Open Windows Schedule task: Start->Settings->Control Panel->Scheduled Tasks
10. Double click Add Scheduled Task and click next when the window pops up
11. Click browse and navigate to the folder you copied the batch files to
12. Click on SVNCheckout.bat, and click Open
13. Click the "Daily" radio button, then click next
14. Set the "Start time" and "Start Date" for the task, then click next
15. Fill in the user name and password if your computer has one. This is so that if your computer hibernates after a certain amount of time, the scheduled task will still activate and not get stuck at a log on screen.
16. Click next, then click finish.
17. Done
That should take care of your nightly build and back up system. The batch files I included are the most basic commands I could think of, but you don't have to stop there. You can set up multiple repository checkouts and builds.
One of my favorite little systems not included here is the blame system, which allows you check for a broken build, find out why it's broken, and blame the person who broke it =). This is a great way of keeping your developers in line, making sure no one checks in bad code.
[EDITS]
Added a fourth file to the .rar in this resource: SVNUpdate.bat. You can use this to perform a quicker update of the repository, instead of a full checkout, if you have already checked out to a folder.
Fixed some mistakes and grammar.
[EDITS]
Common Info:
This tutorial is based on a standard Windows XP/NT operating system, with all programs installed to the default path. Any paths or directories I refer to can be changed to suit your folder hierarchies.
This is an add-on to my previous resource, Step by Step source control setup, so you can refer to that for information not described here.
You will be manipulating Windows environment variables, using automated batch programs, and setting up a Windows Scheduled Tasks.
Programs you need:
Microsoft Visual Studio (this tutorial is using 2005 express)
Subversion (this tutorial is using version 1.3.2)
Command Line Information:
How to open:
1. Start
2. Run
3. Type cmd
4. Press enter
5. cd c: (this just gets you to the root C:\ drive)
Variables Used:
svn - This is a variable containing the path to C:\Program Files\Subversion\bin\svn.exe
%VS80COMNTOOLS% - This is an environment variable that contains the path to Microsoft's Visual Studio tools. Both the tools and the variable are automatically set up for you.
Commands used:
svn checkout - Will perform a full checkout, using a specified address to a repository and checkout directory
svn update - Updates an existing directory containing svn files
cd - Changes directories
xcopy - Copies a folder and all its subdirectories
call - Invokes another batch file
devenv - Invokes developer environment command, used for compiling code without opening Visual Studio.
What to change in the included batch files:
(modify batch files by right clicking them, then left clicking on edit)
1. Change any file paths or directories to match your folder hierarchy, if different from mine.
2. Modify the following line in SVNCheckout.bat:
svn checkout svn://0.0.0.0/myprojectTo contain the address of your repository and project
Setup:
1. Create a folder, C:\nightlyBuild, and check out the current repository you are working from to here.
2. Open the command prompt and test the following command:
svn checkout
3. If you are asked for parameters, skip steps 4-7. If svn is an unknown command, go to step 4.
4. Go to : Start->Settings->Control Panel->System->Advanced->Environment Variables
5. Click New under "System Variables"
6.
- Variable name: svn[li]Variable value: C:\Program Files\Subversion\bin\svn.exe
8. Copy the batch files from this resource to C:\
9. Open Windows Schedule task: Start->Settings->Control Panel->Scheduled Tasks
10. Double click Add Scheduled Task and click next when the window pops up
11. Click browse and navigate to the folder you copied the batch files to
12. Click on SVNCheckout.bat, and click Open
13. Click the "Daily" radio button, then click next
14. Set the "Start time" and "Start Date" for the task, then click next
15. Fill in the user name and password if your computer has one. This is so that if your computer hibernates after a certain amount of time, the scheduled task will still activate and not get stuck at a log on screen.
16. Click next, then click finish.
17. Done
That should take care of your nightly build and back up system. The batch files I included are the most basic commands I could think of, but you don't have to stop there. You can set up multiple repository checkouts and builds.
One of my favorite little systems not included here is the blame system, which allows you check for a broken build, find out why it's broken, and blame the person who broke it =). This is a great way of keeping your developers in line, making sure no one checks in bad code.
[EDITS]
Added a fourth file to the .rar in this resource: SVNUpdate.bat. You can use this to perform a quicker update of the repository, instead of a full checkout, if you have already checked out to a folder.
Fixed some mistakes and grammar.
[EDITS]

Associate Orion Elenzil
Real Life Plus
We use a combination of CruiseControl, SVN, and Fitnesse to build & run automated tests every night.