Monday, November 24, 2008

Setup a basic Continuous Integration process

In this tutorial I'll show how you can get a basic (and free) Continuous Integration process up and running for your Visual Studio project on a windows machine. We'll use Subversion for version control and Team City as our Continuous Integration Server.

Version Control

Visual SVN Server is a great way to get a Subversion service up and running really easy. Download it here.

Start the installer and choose to location where to install Visual SVN ('Location') and the folder where your Subversion Repositories containing your versioned files will be stored ('Repositories').

VisualSVN_1

In this tutorial we'll use the Subversion authentication.

After the installation is complete, fire up the Visual SVN Server Manager (located in Computer Management) and a user for the build process f.e. 'builduser' by clicking the link . Don't forget to add an account for yourself as well.

Create a new repository by right clicking the 'Repositories' node, make sure to check the 'create default structure' box. Some extra information about Subversion can be found in this free book.

VisualSVN_5

Add the users that you made before to your repository via your repository's properties.

Verify that your Visual SVN Server is running by right-clicking your repository and selection 'Browse', you'll need to provide the credentials of one of the users you added before.

Committing your project

Now that you have our version control server set up you'll need to commit your project into version control. To do this you'll need to install Tortoise SVN to communicate with the Subversion (Visual SVN) Server, this can be downloaded here. Tortoise SVN is a Subversion client which is integrates into the windows explorer.

Please install Tortoise by following the steps of the installer.

After you've installed Tortoise you are ready to commit your project. Right click your solution's folder and select 'checkout'. Fill in the 'URL of the repository, this is location of the the repository you created in the Subversion server.

Tortoise_2

You can easily get this URL by opening the Visual SVN Server Manager, right clicking the 'trunk' folder of your repository and select 'Copy URL to Clipboard'. Make sure that the URL points to the 'trunk' (the trunk will contain the latest version of your source code).

After pressing ok, providing your credentials and accepting that the folder isn't empty, Tortoise will create a hidden .svn folder (which contains the status of your files).

You might notice that a red ball with an explanation mark is highlighting your solution's folder.

Tortoise_3

Right click again on the solution's folder and select 'SVN commit'. Now select only the files of your solution that are needed to compile.

Tortoise_4

After pressing OK, you've committed your project.

Continuous Integration

Ok, now the fun part! Getting your Continuous Integration process up and running.

Please download the free Team City Professional edition here and follow the steps of the installer (When you're doing a local install and running vista start the installer as administrator).

When the set up is complete it will automatically open your browser and point it to the Team City Dashboard. Accept the license agreement and create an administrator account.

teamcity_1

Create a new project by providing a name for it.

teamcity_2

Add a build configuration. Fill in the name, the rest of the settings can be left default.

teamcity_3

Continue to the VCS settings and 'Create and attach a VCS root'. Select 'Subversion' as the type of VCS and provide the necessary 'SVN Connection Settings', the URL as the same as the one we used to checkout with Tortoise earlier. The rest of the settings we can ignore. Test and save the connection.

teamcity_4

Set the VCS checkout mode to 'Automatically on Agent', leave checkout directory blank, check 'clean all files before build' and continue to 'Choose Build Runner'.

teamcity_5

Select 'sln2008' as your 'Build Runner' (or sln2005 if you've got a 2005 solution). Provide the relative path to your .sln file. In the case of this tutorial this is './MyProject.sln'.

The rest of the settings can be left default. Save the configuration and select 'Build Triggering' (number 4) on the right side in the 'Build Configuration Steps' menu.

teamcity_6

Check the 'Enable triggering when files are checked into VCS' box and save the configuration. This will make sure that whenever someone commits a change into Subversion the build will be triggered.

Now it's time to run the build for the first time (manually to see if it works)! Click the 'run' button on the top right of the screen (above the 'Build Configuration Steps' menu).

Select the 'Projects' tab on the top left and check of your Project has compiled successfully.

teamcity_7

Now make a change to your project so that it contains a compilation error and commit this change (by right clicking your project folder and selecting 'SVN Commit'. The file you changed should already be selected.

After you've committed your file watch the Team City Dashboard and check that your build is triggered (it may take a few seconds, refresh a few times) and that it fails because of an compilation error.

Fix the compilation error and commit again. Now you'll see that after the build is triggered the build succeeds again!

Done!

Ok, so that's your very own build process! In a next post I'll show how to get your unit tests into the build process.

0 comments: