Set Up TeamCity on Ubuntu 14 LTS

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 https://gist.githubusercontent.com/ChrisMcKee/a45e5cd5d7d9b8f9fa00/raw/2b4a8fea3fcff9e6675e560e908fa785d6ac2697/teamcitysetup.sh && chmod +x teamcitysetup.sh && ./teamcitysetup.sh

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

Set the Java Path ala this post /neither-the-java_home-nor-the-jre_home-environment-variable-is-defined/

Install TeamCity

Check website for current version and substitute.

wget -c http://download.jetbrains.com/teamcity/TeamCity-8.1.5.tar.gz -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 https://gist.githubusercontent.com/sandcastle/9282638/raw/teamcity-init.sh -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 http://jdbc.postgresql.org/download/postgresql-9.3-1102.jdbc41.jar -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

Install

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

Open Postgres shell

sudo su - postgres
psql

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/database.properties

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

connectionUrl=jdbc:postgresql://127.0.0.1/teamcity
connectionProperties.user=teamcity
connectionProperties.password=my-very-secure-password

Start that stuff up.

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

Done

Chris McKee

Chris McKee

https://chrismckee.co.uk

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