TeamCity With Postgres

26 January 2016

Recently, I've been looking for a Jenkins alternative and the closest I found is TeamCity. It's not free as in free speech compared to Jenkins but the twenty build configs and three build agents is more than enough for my small projects.

TeamCity promised to work out-of-the-box just like Jenkins does so I'll give it a go. It's using Tomcat by default so I'm expecting a flat learning curve here.

TeamCity login screen

Download TeamCity

Download TeamCity from https://www.jetbrains.com/teamcity/download and extract it to your chosen destination. I extracted mine in /opt folder.

Run TeamCity

$ ./bin/runAll.sh start
Using CATALINA_BASE:   /opt/TeamCity
Using CATALINA_HOME:   /opt/TeamCity
Using CATALINA_TMPDIR: /opt/TeamCity/temp
Using JRE_HOME:        /opt/jdk/jdk1.8.0_05
Using CLASSPATH:       /opt/TeamCity/bin/bootstrap.jar:/opt/TeamCity/bin/tomcat-juli.jar
Using CATALINA_PID:    ../logs/teamcity.pid
Tomcat started.
Starting TeamCity build agent...
Java executable is found in '/opt/jdk/jdk1.8.0_05'.
Starting TeamCity Build Agent Launcher...
Agent home directory is /opt/TeamCity/buildAgent
Current Java runtime version is 1.8
Lock file: /opt/TeamCity/buildAgent/logs/buildAgent.properties.lock

Check the application

Just browse http://localhost:8111. To change the server port, in the <TeamCity Home>/conf/server.xml file, change the port number in the HTTP/1.1 connector

<Connector port="8111" protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443"
    enableLookup="false"
    useBodyEncodingForURI="true"
/>

Download JDBC driver

In one of the setup screens, you have to choose your database backend. I'm using Postgres so I have to download the JDBC driver and put it on this directory. .BuildServer is the default install folder TeamCity has created in your home folder.

~/.BuildServer$ tree lib
lib
└── jdbc
    └── postgresql-9.3-1103.jdbc41.jar

Create the database backend

$ sudo -u postgres psql postgres
psql (9.3.9)
Type "help" for help.

postgres=# create user teamcity with createdb encrypted password 'TeamCity';
postgres=# create database teamcity with owner teamcity;

Fiddle the application

After an hour of fiddling, I have a successful build. The real challenge is deploying the artifacts. But I'm sure my friend Google has answer.

TeamCity project screen