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.
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:
- 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:
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.
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.
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!