Install and secure MySql isntallation:
apt install mariadb-server
mysql_secure_installation
Setup the MySql database for TeamCity:
Start the MySql client:
mysql -u -p <Root Pasword entered during mysql_secure_installation>
Then issue the following commands:
create database teamcity collate utf8_bin;
create user teamcity identified by '<any password of your choice>';
grant all privileges on teamcity.* to teamcity;
grant process on *.* to teamcity;
Remember the password you selected, it will be needed when setting up TeamCity later.
Install the Java JDK 8
apt install openjdk-8-jdk
Configure the JAVA_HOME
environment variable
echo JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/ >> /etc/environment
source /etc/environment
Execute the following command and answer to the questions:
adduser teamcity
Go to the TeamCity download page for linux.
When the download starts, cancel the download. Then, copy the download link labelled "Direct Link".
Setup the folders, download and extract from the linux machine:
mkdir /opt/JetBrains
cd /opt/JetBrains
wget <The download link you copied before>
tar -xzvf TeamCity*.tar.gz
chown -Rv teamcity:teamcity TeamCity
Install NGINX:
sudo apt-get install nginx
Create and enable the NGINX TeamCity site:
cat << EOF > /etc/nginx/sites-available/teamcity
# We need to support websockets from TC 9.x onwards
# https://confluence.jetbrains.com/display/TCD9/How+To...#HowTo...-SetUpTeamCitybehindaProxyServer
map $http_upgrade $connection_upgrade {
default upgrade;
'' '';
}
server {
listen 80 default_server;
server_name _;
proxy_read_timeout 1200;
proxy_connect_timeout 240;
client_max_body_size 0;
location / {
proxy_pass http://localhost:8111;
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host; # necessary for proper absolute redirects and TeamCity CSRF check
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
EOF
sudo ln -s /etc/nginx/sites-available/teamcity /etc/nginx/sites-enabled/teamcity
sudo rm -rf /etc/nginx/sites-available/default
sudo rm -rf /etc/nginx/sites-enabled/default
sudo service nginx restart
Setup the startup script
cat <<EOF > /etc/init.d/teamcity
#!/bin/sh
### BEGIN INIT INFO
# Provides: TeamCity autostart
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start teamcity daemon at boot time
# Description: Enable service provided by daemon.
# /etc/init.d/teamcity - startup script for teamcity
### END INIT INFO
# Ensure you enter the right user name that TeamCity will run under
USER="teamcity"
# Uncomment and set to the data path to be used by TeamCity
#export TEAMCITY_DATA_PATH="/opt/JetBrains/TeamCity/.BuildServer"
case $1 in
start)
start-stop-daemon --start -c $USER --exec /opt/JetBrains/TeamCity/bin/runAll.sh start
;;
stop)
start-stop-daemon --start -c $USER --exec /opt/JetBrains/TeamCity/bin/runAll.sh stop
;;
esac
exit 0
EOF
chmod +x /etc/init.d/teamcity
update-rc.d teamcity defaults
Start TeamCity:
/etc/init.d/teamcity start
On your machine, open the TeamCity web site (http://your-build-server).
- Verify that the data directory is correct. If not, set the
TEAMCITY_DATA_PATH
environment variable in the/etc/init.d/teamcity
script and restart TeamCity. - Select
MySql
as the database type.- Click [Download JDBC Driver]
- Enter the following values for the connexion
- Database host: leave empty
- Database name: enter
teamcity
- User name: enter
teamcity
- Password: enter the password you selected while creating the teamcity MySQL user
- Wait until initialize completes. This might take some time...
- Accept the licence agreement
- Create the admin account
- Complete your profile and done !