Set Up TeamCity on Ubuntu 14 LTS

Prep essentials

Change versions to latest as required...

SSH into your server and let's begin.

Go root, type sudo su.

Cheat mode (skip to : Create a Database Config file for PostGres) wget && chmod +x && ./

apt-get update  
apt-get install -y openjdk-7-jre-headless curl mercurial git  

Set the Java Path ala this post /neither-the-javahome-nor-the-jrehome-environment-variable-is-defined/

Install TeamCity

Check website for current version and substitute.

wget -c -O /tmp/TeamCity-8.1.5.tar.gz  
tar -xvf /tmp/TeamCity-8.1.5.tar.gz -C /srv  
rm -rf /tmp/TeamCity-8.1.5.tar.gz  
mkdir /srv/.BuildServer  

Create a TeamCity user

useradd -m teamcity  
chown -R teamcity /srv/TeamCity  
chown -R teamcity /srv/.BuildServer  

Create init.d script

wget -O /etc/init.d/teamcity  
chmod 775 /etc/init.d/teamcity  
update-rc.d teamcity defaults  

Download PostGres ODBC driver for TeamCity

mkdir -p /srv/.BuildServer/lib/jdbc  
mkdir -p /srv/.BuildServer/config  
wget -O /srv/.BuildServer/lib/jdbc/postgresql-9.3-1102.jdbc41.jar  

Change ownership of files

sudo chown -R teamcity /srv/TeamCity  
sudo chown -R teamcity /srv/.BuildServer  

Create a Database Config file for PostGres


apt-get update && apt-get install -y postgresql postgresql-contrib  

Open Postgres shell

sudo su - postgres  

Enter the following to create the user and teamcity db (note your password you'll need it for the config)

create role `teamcity` with login password 'my-very-secure-password';  
create database `teamcity` owner `teamcity`;  

Type \q and hit enter to exit PostGres shell.
Then type exit to un-assume the Postgres user, and let's reset postgres aswell (you should still be root at this point, sudo if not) /etc/init.d/postgresql restart

nano /srv/.BuildServer/config/  

Paste this in (or type it, if you're a sadist)


Start that stuff up.

/etc/init.d/postgresql start (if its not started)
/etc/init.d/teamcity start


Chris McKee

Chris McKee

Software Engineer, Web Front/Backend/Architecture; all-round tech obsessed geek. I hate unnecessary optimism

View Comments