Running TeamCity from Amazon EC2 - Cloud based scalable build and continuous Integration

Posted on Dot net Slackers See other posts from Dot net Slackers
Published on Mon, 31 May 2010 00:00:00 GMT Indexed on 2010/05/31 14:23 UTC
Read the original article Hit count: 531

Filed under:
Ive been having fun playing with the amazon EC2 cloud service. I set up a server running TeamCity, and an image of a server that just runs a TeamCity agent. I also setup TeamCity  to automatically instantiate agents on EC2 and shut them down based upon availability of free agents. Heres how I did it: The first step was setting up the teamcity server. Create an account on amazon EC2 (BTW, amazons sites works better in IE than it does in chrome.. who knew!?) Open the EC2 dashboard, and...

Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.



Email this Article

© Dot net Slackers or respective owner

Running TeamCity from Amazon EC2 - Cloud based scalable build and continuous Integration

Posted on Dot net Slackers See other posts from Dot net Slackers
Published on Mon, 31 May 2010 00:00:00 GMT Indexed on 2010/05/31 14:34 UTC
Read the original article Hit count: 531

Filed under:
Ive been having fun playing with the amazon EC2 cloud service. I set up a server running TeamCity, and an image of a server that just runs a TeamCity agent. I also setup TeamCity  to automatically instantiate agents on EC2 and shut them down based upon availability of free agents. Heres how I did it: The first step was setting up the teamcity server. Create an account on amazon EC2 (BTW, amazons sites works better in IE than it does in chrome.. who knew!?) Open the EC2 dashboard, and...

Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.



Email this Article

© Dot net Slackers or respective owner

Running TeamCity from Amazon EC2 - Cloud based scalable build and continuous Integration

Posted by RoyOsherove on ASP.net Weblogs See other posts from ASP.net Weblogs or by RoyOsherove
Published on Mon, 31 May 2010 12:53:02 GMT Indexed on 2010/05/31 12:54 UTC
Read the original article Hit count: 531

Filed under:
|

I’ve been having fun playing with the amazon EC2 cloud service. I set up a server running TeamCity, and an image of a server that just runs a TeamCity agent. I also setup TeamCity  to automatically instantiate agents on EC2 and shut them down based upon availability of free agents.

Here’s how I did it:

The first step was setting up the teamcity server.

  1. Create an account on amazon EC2 (BTW, amazon’s sites works better in IE than it does in chrome.. who knew!?)
  2. Open the EC2 dashboard, and click “Launch Instance” .
  3. From the “Quick Start” tab I selected from the list: “Getting Started on Microsoft Windows Server 2008 (AMI Id: ami-c5e40dac)” .  it’s good enough to just run teamcity.
  4. In the instance details, I used the default (Small instance, 1.7 GB mem). You might want to choose a close availability zone based on where you are.
  5. We want to “Launch instances” so click continue.
  6. Select the default kernel, RAM disk and all. No need to enable monitoring for now (you can do that later). click continue.
  7. If you don’t have a key pair, you will be prompted to create one. Once you do, select it in the list.
  8. Now you’ll be prompted to create a security group. I named mine “TC” as in “TeamCity”. each group is a bunch of settings on which ports can be let through into and out of a hosted machine.  keep it as the default settings. We will change them later.
  9. Click continue,  review and then click “Launch”. Now you’ll be able to see the new instance in the running instances list on your site.
  10. Now, you need to install stuff on that instance (TeamCity!) . To do that, you’ll need to Remote desktop into that instance. To do that, we’ll get the admin password for that instance: Check it on the list, and click “Instance Actions” - “Get Windows Admin Password”. You might have to wait about 10 minutes or so for the password to be generated for you.
  11. Once you have the password, you will remote desktop (start-run-‘mstsc’) into the instance. It’s address is a dns address shown below the list under “Public DNS”. it looks something like: ec2-256-226-194-91.compute-1.amazonaws.com
  12. Once you’re inside the instance – you’ll need to open IE (it is in hardened mode so you’ll have to relax its security settings to download stuff). I first downloaded chrome and using chrome I downloaded TeamCity. Note that the download speed is FAST. several MBs per second.
  13. To be able to see TeamCity from the outside, you will need to open the advanced firewall settings inside the remote machine, and add incoming and outgoing rules for port 80 (HTTP). Once you do that, you should be able to see the machine from the outside. If you still can’t, see the next step. I also enabled ports 9090 since I will use this machine to create an agent image later as well.
  14. Now configure the security group (TC) to enable talking to agents: IN the EC2 dashboard click on “Security Groups” and select your group. To add a rule, click on the empty list under the ‘protocol’ header. select TCP. from and ‘to’ ports are 9090. source ip is 0.0.0.0/0 (every ip is allowed). click “Save.  Also make sure you can see “HTTP” tcp 80 in that list. if you can’t see it, add it or you won’t be able to browse to the machine’s teamcity server home page.
  15. I also set an elastic IP for the machine: so I always have the same IP for the machine instance. Allocate and set one through the”Elastic IP” link on the EC2 dashboard.

 

you should now have a working instance of teamcity.

 

Now let’s create an agent image.

Repeat steps 1-9, but this time, make sure you select a machine that fits what an agent might do. I selected Instance type – Hihg-CPU medium machine,  that is much faster. On that machine, I installed what I needed (VS 2010, PostSharp etc..). downloading VS 2010 from MSDN (2 GB took less than 10 min!)

Now, instead of installing teamcity, browse using the browser to the teamcity homepage (from within the remote machine). go to the Administration page, and click the upper right link “Install agents”.

  • Install the agent on he local machine – set it to the IP or DNS of the running TeamCity server. That way you’ll be able to check their connectivity live before making this machine your official agent image to reuse.
  • Once the agent is installed, see that the TC server can see it and use it. see steps 13-14 above if they can’t.
  • Once it works, you can take steps to make this image your agent image to be reused.

next, here is a copy-paste of several steps to take from http://confluence.jetbrains.net/display/TCD5/Setting+Up+TeamCity+for+Amazon+EC2

  • Configure system so that agent it is started on machine boot (and make sure TeamCity server is accessible on machine boot).
  1. Test the setup by rebooting machine and checking that the agent connects normally to the server.
  2. Prepare the Image for bundling:
    • Remove any temporary/history information in the system.
    • Stop the agent (under Windows stop the service but leave it in Automatic startup type)
    • Delete content agent logs and temp directories (not necessary)
    • Delete "<Agent Home>/conf/amazon-*" file (not necessary)
    • Change config/buildAgent.properties to remove properties: name, serverAddress, authToken (not necessary)

 

Now, we need to:

  1. Make AMI from the running instance.
  2. Configure TeamCity EC2 support on TeamCity server.

Making an AMI:

  • Check the instance of the agent in the EC2 dashboard instance list, and select instance actions->Create Image (EBS AMI)
  • you’ll see the image pending in the APIs list in the EC2 dashboard. this could take 30 minutes or more. meanwhile we can configure the could support in the teamcity server.

COPY THE AMI ID to the clipboard (looks like ami-a88aa4ce)

Configuring TeamCity for Cloud:

  • In TeamCity, click on “Agents” and then on “Cloud” tab. this is where you will control your cloud agents.
  • to configure new cloud agents based on APIs, click on the right link to the “configuration page”
  • Create a new profile and select AMazon EC2 as cloud type. Use your AMI ID that you copied to the clipboard into the “Images” field.
  • Select an availability zone that is the same as the one your instance is running on for best communication perf between them
  • make sure you select the ‘TC’ security group

hopefully, that should be it, and teamcity will try to instantiate new instances on demand. Note that it may take around 10 minutes for an agent to become available to teamcity from the time it’s started.

© ASP.net Weblogs or respective owner

Related posts about .NET

Related posts about agile