In my most recent endeavor, I am redesigning the build process for a new project. I've decided to use Git for source control, TeamCity for CI (Continuous Integration), Amazon EC2 for hosting the CI server, and a MediaTemple Dedicated Virtual server for hosting the production and staging sites.
Though some people may have you believe setting this all up is easy, I can comfortably admit that in my experience it has not been. Hence, the blog posts which will serve to remind me how to get back into this mess should I ever accidentally find my way out.
What This Article Will Cover
- What is TeamCity?
- Where does it fit in?
- Setting up TeamCity
- Downloading and installing TeamCity on an Amazon EC2 instance
- Configuring TeamCity
What is TeamCity?
TeamCity is "proprietary continuous-integration server by JetBrains with free professional edition" (Wikipedia). I'm not going to explain what CI is so if you don't know please ask Wikipedia. After having set up Git properly, I found that GitHub has has built in functionality to integrate with TeamCity. Considering my setup goals of having exactly that, my next logical step is to go check out TeamCity.
Honestly, I did not even know if TeamCity was a downloadable program meant for local use, a web service, a program meant for server use, etc. Since we've got multiple people on our team, I'd like to keep the amount of local configuration for each member to a minimum. I'd also like to be able to administer this setup and make changes, on the fly without having to bother the other guys. Fortunately, after poking around a lot what I have found out is that TeamCity is capable of doing this. We will do it by installing it on an Amazon EC2 instance (but this is not the only way - you could use your own server.)
Where does it fit in?
Here is a diagram of my current project's software stack/architecture. It includes some of what we currently have implemented, as well as everything we'd like to eventually have. You can see where TeamCity fits into the system.

Figure 1-1 - Our application roadmap
Basically TeamCity listens to your Git repository for changes. As soon as a push occurs on Git, TeamCity spins up (another) Amazon EC2 instance, then the TeamCity build agent starts up and fires off some Maven commands. These commands will sequentially kick off the following general functions:
- Validate and compile JavaScript
- Run unit tests on JavaScript and PHP
- Run integration tests in Selenium
- If everything passes, kick off a build into production
I will likely go into thorough detail on each of these steps in a future post since as with everything else, I tend to forget which process I went through.
Setting up TeamCity
Since TeamCity is an application you download, you'll need a machine to run it on. Either you can run it on your local machine, or set it up on a public web server like Amazon EC2 (which is what we're going to do). Read this post on Setting up an Amazon EC2 Server to Run TeamCity if you do not already have it set up.
Downloading and installing TeamCity on an Amazon EC2 instance
This is where I got stuck. Basically I didn't know how to download a file from the command line in Linux. I knew I could click a link from a browser and then execute the file that way. I just didn't have this one critical piece of information. In case you are in the same 0.01 percent of the population as I was, the solution is a command called "wget". I don't know why I never knew it. I just didn't (I even saw the Social Network.)
Now that I've forked over that embarrassing little nugget, let's just get to it already.
Type this into your command line:
wget http://download.jetbrains.com/teamcity/TeamCity-6.0.3.tar.gz
Provided you haven't navigated yourself into a restricted folder before you pressed Enter, this should work without issue.
To install the instance, next we need to unpack the download. Type this into your command line and press Enter:
tar -xvzf TeamCity-6.0.3.tar.gz
Note about the "-xvzf" (all lowercase) parameters:
- x means "extract files from an archive". This is required because a .tar file is an archive.
- v means "verbosely list files processed". It's not necessary but will give you a better understanding of what changes are being made.
- z means "filter the archive through gzip". This is required because the .gz indicates this file has been compressed using gzip, and so needs to be decompressed using gzip.
- f means "force-local" or "archive file is local even if it has a colon". I can only imagine this prevents some bad stuff from happening. Honestly though IDK.
If everything went as planned, you should have seen a bunch of text flying by for a few seconds, and then you should see a quiet little command line. The unpacking process should have created a new folder on your machine called TeamCity. What we have now is an application installed which is only waiting to be started so we can access it from a web browser. To do just this, type the following into the command line and press Enter:
cd TeamCity bin/teamcity-server.sh start
Unfortunately I ran into some very weird problems at this point (which have since been resolved) related to my webserver access configuration which apparently was preventing me from accessing my TeamCity web interface. I may update this post with that information if enough people tell me they have the same problem. I don't think my problem was a fluke considering everything (even the EC2 instance) was a fresh install. So in the spirit of moving on (sorry) I'm going to assume you did not run into the same problems as me here. If in fact you did not have problems, then you should be able to simply access your new TeamCity install by following the link provided by Amazon for your EC2 server + "/TeamCity" (See this post: Figure 2-11 - Connect Help - Secure Shell (SSH)). Please let me know in the comments if you get hung up here and I will be happy to dig up the details and elaborate.
Configuring TeamCity
Now that you have an EC2 instance running which you have installed and can access your TeamCity server, you will need to configure it to do the interesting stuff that we described above.
Since I believe this topic warrants it's own post, I have done just that. Please read: [link removed] ...I'm still working on this part.
In closing
Hopefully this has provided you with some helpful info. If you've got any questions please drop them in the comments below. They're more likely to get answered there either by me or someone else as this is a fairly highly trafficked blog.
Thanks for reading!
Helpful Articles
http://www.dennisplucinik.com/blog/2011/04/06/setting-up-an-amazon-ec2-server-to-run-teamcity/
http://www.modelmetrics.com/wp-content/uploads/2011/01/Teamcity-install.pdf
http://confluence.jetbrains.net/display/TCD65/Setting+Up+TeamCity+for+Amazon+EC2
//http://osherove.com/blog/2010/5/31/running-teamcity-from-amazon-ec2-cloud-based-scalable-build.html
Related Books

Hi -Really useful.
You’re not alone! I never knew wget either as we didn’t use http much when I was at uni!
AWS are also offering a free 24/7 micro instance if you sign-up as a new customer. (see http://aws.amazon.com/free/) This is really handy if you are just trying this stuff out, or if you want to have a ‘monitoring’ server that kicks off other (bigger and paid for) instances as required.
Andy
Hi – very usefulset of articles, thanks! Regarding the wierd access problems that you had when you first installed TeamCity, could you elaborate? I’ve followed everything, but whem I browse to /TeamCity, I get no response at all – is this what you had? Thanks, Paul.
@Paul – yes, it ended up being a problem with the port not being set correctly so I tried to change the port number and realized that the user I was logged in as (ec2-user) did not have rights to make that change, so I think I had to make a change in the vhost setting to point to a different port. I’m not sure if that 100% covers it but it may point you in the right direction.
Team City by default gets installed on on port 8111.
You can either a) change the port
b) Leave it on 8111 and allow 8111 through the AWS firewall.
Open AWS. Goto Networking & Security
Click on the security group for you server.
In the bottom part of the screen, click the ‘Inbound’ tab.
Create a new rule: Custom TCP rule
Port range 8111
Source: 0.0.0.0 (0 = everyone or if you have a static IP lock it down and put your static IP)
Add Rule
Remember to click ‘Apply Rule Changes’ (I didn’t first time)
Browse to :8111
Pingback: Slowly, Slowly, Catchy Monkey « So, You Think You Need To Rewrite?
Pingback: Setting up an Amazon EC2 Server to Run TeamCity | Dennis Plucinik's Web Design Blog
Very-very useful! Thanks!
Hi Dennis,
Thanks for the info! I was just trying to get TeamCity running on a linux box. Being rather new to linux I was sure I had to do more than simply unpack the tar file and run the start script. If all of linux is like this, i could definitely get used to it
Ken – what’s up brotha? How’s life at Huge?
Re: CI I honestly haven’t gotten past the last step in this process, and since I started writing this series TeamCity now has taken care of a few of these steps for you. I’ll return to it eventually when I need to build and deploy a larger project of my own in the future.
Glad I could be of some help though.
Hi, i just created a Ubuntu 12.04 EC2 Instance. Downloaded and upacked Teamcity 7.1.4. When i start the script.. i get this message:
Using CATALINA_BASE: /home/ubuntu/Application/TeamCity714
Using CATALINA_HOME: /home/ubuntu/Application/TeamCity714
Using CATALINA_TMPDIR: /home/ubuntu/Application/TeamCity714/temp
Using JRE_HOME: /usr
Using CLASSPATH: /home/ubuntu/Application/TeamCity714/bin/bootstrap.jar:/home/ubuntu/Application/TeamCity714/bin/tomcat-juli.jar
But the server is not starting. what im doing wrong?
thanks in advanced.
Solved.
I had wrong PATH and JRE_HOME Variable. I added also /bin to the JRE_HOME and this is wrong.