From Nottinghack Wiki
Jump to: navigation, search

Install Java

To install Java on Debian I followed this guide:

Download the Linux version of the server JRE from

wget --header "Cookie: oraclelicense=accept-securebackup-cookie"

mkdir /opt/jdk

tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk

update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_05/bin/java 100

update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_05/bin/javac 100

Install TeamCity

Download the .tar.gz version of TeamCity from:

mkdir /var/teamcity
tar -zxf TeamCity-8.1.5.tar.gz -C /var/teamcity

Next create a service start/stop script for TeamCity at /etc/init.d/teamcity

#! /bin/sh
# /etc/init.d/teamcity

# This stops TeamCity dumping it's data in /root/.BuildServer
export TEAMCITY_DATA_PATH="/var/TeamCity/.BuildServer"

# Carry out specific functions when asked to by the system
case "$1" in
    echo "Starting script teamcity "
    /var/TeamCity/bin/ start
    echo "Stopping script teamcity"
    /var/TeamCity/bin/ stop
    echo "Usage: /etc/init.d/teamcity {start|stop}"
    exit 1

exit 0

Next add it to the boot procedure:

chmod 755 /etc/init.d/teamcity
update-rc.d teamcity defaults

Start TeamCity:

service teamcity start

TeamCity should now start after a minute or two and be available at localhost:8111 for initial configuration.

Install MySQL Connector

TeamCity requires a database to store it's data. As we're using MySQL for HMS, it makes sense to make use of the installed server. TeamCity does not ship with the MySQL connector so it must be downloaded and installed manually from

tar -zxf mysql-connector-java-5.1.33.tar.gz
mv mysql-connector-java-5.1.33/mysql-connector-java-5.1.33-bin.jar /var/TeamCity/.BuildServer/lib/jdbc/

Alter startup configuration

I altered the startup config for TeamCity by editing /var/TeamCity/bin/ and uncommented the line mentioned below, this increases the memory available to the JVM. I also added an additional java flag to the options -XX:+UseConcMarkSweepGC which should improve garbage collection performance.

# Options recommended for dedicated server installation (commented by default)
TEAMCITY_SERVER_MEM_OPTS="-Xms750m -Xmx750m -XX:MaxPermSize=270m -XX:+UseConcMarkSweepGC"

PHP meta-runners for TeamCity

A TeamCity meta-runner is essentially a reusable template for a set of build steps. There are a few useful PHP ones on github:

I have installed the following into the HMS project:

  • MRPP_PHP_Composer.xml
cd /var/TeamCity/.BuildServer/config/projects/HMS/pluginData
mkdir metaRunners
cd metaRunners

The meta-runner should appear in the list when creating the build plan without the need to restart the TeamCity server.

PHP Extensions

Some of the dependencies used by HMS are installed by Composer. There were a few dependencies which would not install until specific PHP extensions were present.

aptitude install php5-curl
aptitude install php5-xsl

PEAR packages

To be able to run the PHP code sniffer during the build, the agent must have certain PEAR packages installed:

pear install PHP_CodeSniffer
pear channel-discover
pear install cakephp/CakePHP_CodeSniffer