Sunday, April 21, 2013

How to Automate Builds with TeamCity (Part 2)

Please notice that this is a multi-part, step-by-step guide, on how to automate builds in TeamCity CI Server. You can find the parent article here, which has links to all the related posts.

Part 2:  Creating the Build Project in TeamCity

The following steps will guide you through the process of creating a Build project in TeamCity. You first need to have your project setup, including general information and version source control settings, so you can later add build steps and parameters to execute when changes are committed.

  1. Login into TeamCity’s administration panel.
  2. Click on the Administration link at the top right corner, next to the search box.

  3. On the left, the list of configured projects will be displayed, which will be empty if you haven’t configured any projects before.
  4. At the top, you have two tabs: Active Projects and Archived Projects. Make sure you are on the first tab.

  5. Below the tab you should see a “Create Project” button. Click on it to create a project.

  6. The New project page will be displayed. Fill in the project name and description fields and click the “Create” button. Make sure the project name is accurate, meaningful and unique.

  7. The basic project will be created and you will see the project general details you entered with a notification above suggesting to add a build configuration. Let’s do that.
  8. Click on the “Create build configuration” link, which should be below the project details.

  9. The General Settings Page for the Build configuration will be displayed. Here’s is where you actually configure a CI Build. Keep in mind that commonly, you will create a new configuration for each application/solution for each environment. Let’s assume that we are creating our development Build configuration for our MVC application.
  10. Fill in the Name and Description fields. For now, let’s leave all the other fields with their defaults. The only exception is to tick the checkbox for the option “it runs longer than X minutes” and add the minute’s value. I have tentatively entered 10 minutes, which is definitely far too long, but it will do for now. Then click on the VCS settings.

  11. The next step is to enter the version control settings. Here you will need to create a new VCS root and attach it to the project’s Build configuration. Here, you are effectively configuring the source control repo’s setting where TeamCity will look for the project files.

  12. Click on the “Create and attach new VCS root” button.
  13. First you need to select the source control tool you are using. This depends on what you are using. In this simple case, I’m using Subversion (SVN), so that’s what I’m choosing. Settings will slightly change depending on the source control tool, but they should be straight forward.

  14. You will be required to enter the VCS root name and the SVN connection settings, including the URL of the repo for the project (root folder of the repo), and the credentials. You can configure SSH settings if you need to. You can also make the VCS root available to other projects if you want, which is helpful if you plan to have different TeamCity projects per environment, which need to access the same root repo. In this case, I plan to create all the environment builds within the same TeamCity project for the MVC app, so I’m leaving this unchecked.

  15. When finished entering the details, you can click on the “Test Connection” button to make sure the TeamCity is able to view and connect to the repo. If not successful, check the connection settings. When the connection is working, click on the “Save” button.

  16. You will be taken back to the Build Configuration page, and a notification will be displayed telling you that the VCS root was created. You can now see that there is a VCS root configured, with the details you just entered. This means that your Build project is already connected to the root of your application’s source control repo.
  17. You can now change some source control settings, like the checkout mode, the checkout directory and the labelling rules. In this case, I’m leaving everything with the defaults.

Good work. We have now a Build project in out TeamCity CI Server. We are ready to start creating build steps.


Part 3: Creating the Build Step in TeamCity

No comments:

Post a Comment