Skip to content

Instantly share code, notes, and snippets.

@ryanbillingsley
Forked from sandcastle/install-teamcity.md
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanbillingsley/5c6641c15aafcd8aa06e to your computer and use it in GitHub Desktop.
Save ryanbillingsley/5c6641c15aafcd8aa06e to your computer and use it in GitHub Desktop.

Install

Follow the steps below to install Team City 8.1 on Ubuntu 12.04 with Nginx as the proxy for port 80.

Install Team City:

# will install on port 8111
sudo wget -c https://gist.github.com/ryanbillingsley/5c6641c15aafcd8aa06e/raw/50ec6ce84da8162de9359ee746e5f8c767b7cb75/teamcity-install.sh -O /tmp/teamcity-install.sh
sudo sh /tmp/teamcity-install.sh
sudo rm -rf /tmp/teamcity-install.sh

Install Postgres 9.3:

See postgres-9-3.md below

Update the database settings:

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

Install Nginx:

#will proxy port 80 to team city on 8111
sudo wget -c https://gist.githubusercontent.com/sandcastle/9282638/raw/nginx.sh -O /tmp/nginx.sh
sudo sh /tmp/nginx.sh
sudo rm -rf /tmp/nginx.sh

Update nginx config:

sudo nano /etc/nginx/sites-available/teamcity

Remove the default ngnix server:

sudo rm -rf /etc/nginx/sites-enabled/default
sudo rm -rf /etc/nginx/sites-available/default

Start it up:

sudo /etc/init.d/nginx start
sudo /etc/init.d/teamcity start

Commands:

#start team city
sudo /etc/init.d/teamcity start

#stop team city
sudo /etc/init.d/teamcity stop

#star nginx
sudo /etc/init.d/nginx start

#stop nginx
sudo /etc/init.d/nginx stop

#reload nginx
sudo /etc/init.d/nginx reload

#test team city on port 8111
curl http://localhost:8111

#test team city on port 80
curl http://localhost:80
server {
client_max_body_size 150M;
listen 80;
server_name localhost <yourdomainname.com>;
root /var/www/teamcity;
location / {
proxy_pass http://127.0.0.1:8111;
}
}
#!/bin/sh
# install nginx
sudo apt-get install -y nginx
# update the config
sudo wget https://gist.githubusercontent.com/sandcastle/9282638/raw/nginx.conf -O /etc/nginx/sites-available/teamcity
sudo mkdir -p /var/www/teamcity
# create syn link
sudo ln -s /etc/nginx/sites-available/teamcity /etc/nginx/sites-enabled/teamcity
# reload
sudo /etc/init.d/nginx reload

Install

The following steps should be followed to install and configure postgres.

Install postgres 9.3:

sudo apt-get update
sudo apt-get install postgresql postgresql-contrib

Configure remote access:

# open the file and append the lines below
sudo nano /etc/postgresql/9.3/main/pg_hba.conf

# remote access (where x.x.x.x is your IP)
host all all x.x.x.x/32 md5

# servers (repeat this line per server)
host all all x.x.x.x/32 md5

Configure listening:

# open the file and change the lines below
sudo nano /etc/postgresql/9.3/main/postgresql.conf

listen_addresses = '*'

Access the psql command line:

# switch user to the postgres user
sudo su - postgres

# load the command line
psql

# create the team city user
create role teamcity with login password '<password>';
create database teamcity owner teamcity;

Restart postgres:

sudo /etc/init.d/postgresql restart
connectionUrl=jdbc:postgresql://<host>/teamcity
connectionProperties.user=<user>
connectionProperties.password=<password>
#!/bin/sh
# /etc/init.d/teamcity - startup script for teamcity
export TEAMCITY_DATA_PATH="/srv/.BuildServer"
case $1 in
start)
echo "Starting Team City"
start-stop-daemon --start -c teamcity --exec /srv/TeamCity/bin/teamcity-server.sh start
;;
stop)
echo "Stopping Team City"
start-stop-daemon --start -c teamcity --exec /srv/TeamCity/bin/teamcity-server.sh stop
;;
restart)
echo "Restarting Team City"
start-stop-daemon --start -c teamcity --exec /srv/TeamCity/bin/teamcity-server.sh stop
start-stop-daemon --start -c teamcity --exec /srv/TeamCity/bin/teamcity-server.sh start
;;
*)
echo "Usage: /etc/init.d/teamcity {start|stop|restart}"
exit 1
;;
esac
exit 0
#!/bin/bash
cd /
# install server dependencies
sudo apt-get update
sudo apt-get install -y openjdk-7-jre-headless
sudo apt-get install -y curl
# install build agent dependencies
sudo apt-get install -y mercurial
sudo apt-get install -y git
# install team city
sudo wget -c http://download.jetbrains.com/teamcity/TeamCity-8.1.5.tar.gz -O /tmp/TeamCity-8.1.5.tar.gz
sudo tar -xvf /tmp/TeamCity-8.1.5.tar.gz -C /srv
sudo rm -rf /tmp/TeamCity-8.1.5.tar.gz
sudo mkdir /srv/.BuildServer
# create user
sudo useradd -m teamcity
sudo chown -R teamcity /srv/TeamCity
sudo chown -R teamcity /srv/.BuildServer
# create init.d script
sudo wget https://gist.githubusercontent.com/sandcastle/9282638/raw/teamcity-init.sh -O /etc/init.d/teamcity
sudo chmod 775 /etc/init.d/teamcity
sudo update-rc.d teamcity defaults
# download postgres
sudo mkdir -p /srv/.BuildServer/lib/jdbc
sudo mkdir -p /srv/.BuildServer/config
sudo wget http://jdbc.postgresql.org/download/postgresql-9.3-1101.jdbc41.jar -O /srv/.BuildServer/lib/jdbc/postgresql-9.3-1101.jdbc41.jar
sudo wget https://gist.githubusercontent.com/sandcastle/9282638/raw/postgres.database.properties -O /srv/.BuildServer/config/database.properties
# ensure owership
sudo chown -R teamcity /srv/TeamCity
sudo chown -R teamcity /srv/.BuildServer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment