Skip to content

Instantly share code, notes, and snippets.

@buldo
Forked from sandcastle/install-teamcity.md
Last active May 25, 2016 16:38
Show Gist options
  • Save buldo/a205782a0395b4693c7e3b73712a21da to your computer and use it in GitHub Desktop.
Save buldo/a205782a0395b4693c7e3b73712a21da to your computer and use it in GitHub Desktop.
Install TeamCity

Install

Install OracleJDK

apt-get install software-properties-common python-software-properties #for minimal ubuntu  
sudo add-apt-repository ppa:webupd8team/java  
sudo apt-get update  
sudo apt-get install oracle-java8-installer  
sudo apt-get install oracle-java8-set-default  

Install git

sudo apt-get install git  

Install TeamCity

sudo wget -c https://download.jetbrains.com/teamcity/TeamCity-9.1.7.tar.gz -O /tmp/TeamCity-9.1.7.tar.gz  
sudo tar -xvf /tmp/TeamCity-9.1.7.tar.gz -C /opt  
sudo rm -rf /tmp/TeamCity-9.1.7.tar.gz  
sudo mkdir /opt/.BuildServer  

sudo useradd -m teamcity  
sudo chown -R teamcity /opt/TeamCity  
sudo chown -R teamcity /opt/.BuildServer  

Create init.d script

Copy script to /etc/init.d/teamcity

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

Download postgres

sudo mkdir -p /opt/.BuildServer/lib/jdbc  
sudo mkdir -p /opt/.BuildServer/config  
sudo wget https://jdbc.postgresql.org/download/postgresql-9.4.1208.jar -O /opt/.BuildServer/lib/jdbc/postgresql-9.4.1208.jar  

Copy database.properties to /opt/.BuildServer/config/database.properties

Ensure owership

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

Install Postgres

sudo apt-get install postgresql postgresql-contrib
sudo su - postgres
psql
create role teamcity with login password '<password>';
create database teamcity owner teamcity;
sudo /etc/init.d/postgresql restart

Update the database settings:

sudo nano /srv/.BuildServer/config/database.properties

Start it up:

sudo /etc/init.d/teamcity start
connectionUrl=jdbc:postgresql://<host>/teamcity
connectionProperties.user=<user>
connectionProperties.password=<password>
#!/bin/sh
### BEGIN INIT INFO
# Provides: teamcity
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Should-Start: $named $syslog $time
# Should-Stop: $named $syslog $time
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: initscript for teamcity
# Description: initscript for teamcity
### END INIT INFO
export TEAMCITY_DATA_PATH="/opt/.BuildServer"
case $1 in
start)
echo "Starting Team City"
start-stop-daemon --start -c teamcity --exec /opt/TeamCity/bin/teamcity-server.sh start
;;
stop)
echo "Stopping Team City"
start-stop-daemon --start -c teamcity --exec /opt/TeamCity/bin/teamcity-server.sh stop
;;
restart)
echo "Restarting Team City"
start-stop-daemon --start -c teamcity --exec /opt/TeamCity/bin/teamcity-server.sh stop
start-stop-daemon --start -c teamcity --exec /opt/TeamCity/bin/teamcity-server.sh start
;;
*)
echo "Usage: /etc/init.d/teamcity {start|stop|restart}"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment