HMS/Development/TeamCity

From Nottinghack Wiki
Jump to: navigation, search

Install Java

To install Java on Debian I followed this guide: https://www.digitalocean.com/community/tutorials/how-to-manually-install-oracle-java-on-a-debian-or-ubuntu-vps

Download the Linux version of the server JRE from http://www.oracle.com/technetwork/java/javase/downloads/index.html:

wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u20-b26/server-jre-8u20-linux-x64.tar.gz

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: http://www.jetbrains.com/teamcity/download/

wget http://download.jetbrains.com/teamcity/TeamCity-8.1.5.tar.gz
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
  start)
    echo "Starting script teamcity "
    /var/TeamCity/bin/runAll.sh start
    ;;
  stop)
    echo "Stopping script teamcity"
    /var/TeamCity/bin/runAll.sh stop
    ;;
  *)
    echo "Usage: /etc/init.d/teamcity {start|stop}"
    exit 1
    ;;
esac

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 http://dev.mysql.com/downloads/connector/j.

wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.33.tar.gz
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/teamcity-server.sh 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: https://github.com/JetBrains/meta-runner-power-pack

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
wget https://raw.githubusercontent.com/JetBrains/meta-runner-power-pack/master/php/MRPP_PHP_Composer.xml

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.cakephp.org
pear install cakephp/CakePHP_CodeSniffer