Monday, November 16, 2020

How to Install Teamcity on AWS Ubuntu EC2 | How to setup TeamCity on Ubuntu 18.0.4 with PostgreSQL?

TeamCity is one of the CI tools, It is open source and Java based tool. It can be configured easily.

Please find below steps for installing TeamCity on Ubuntu:

Pre-requistes:
Make sure Ubuntu instance has at least 4 GB RAM
Open port 8111 in security firewall.

We need to setup database for storing all the build information. We will be using PostgreSQL.

PostgreSQL Installation
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'

 
sudo wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -



sudo apt-get -y install postgresql postgresql-contrib







 
sudo systemctl start postgresql
sudo systemctl enable postgresql

Login as postgres user
sudo su - postgres

Now create a user below
createuser teamcity

Switch to sql shell by entering
psql

 
 
 
 
 
 
Execute the below three lines (one by one)
 
ALTER USER teamcity WITH ENCRYPTED password 'password';
CREATE DATABASE teamcity OWNER teamcity;
\q

type exit to come out of postgres user.

TeamCity Installation

Download Java
sudo apt-get update && sudo apt-get install default-jdk -y

Download TeamCity

wget https://download.jetbrains.com/teamcity/TeamCity-2020.1.5.tar.gz

Extract TeamCity
tar -xvf TeamCity-2020.1.5.tar.gz
sudo mkdir /opt/JetBrains
sudo mv TeamCity /opt/JetBrains/TeamCity
cd /opt/JetBrains/TeamCity
 
Create service file

sudo nano /etc/init.d/teamcity
(copy the whole text colored in green)
#!/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="ubuntu"

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

Ctrl + O enter
Ctrl + X enter
sudo chmod +x /etc/init.d/teamcity
sudo update-rc.d teamcity defaults
sudo /etc/init.d/teamcity start

Access logs files
cat /opt/JetBrains/TeamCity/buildAgent/logs/teamcity-agent.log

Now access Teamcity UI

Open browser and access team city url in the browser
http://public_dns_name:8111

Click on Proceed.
Select database type as jdbc driver as Postgres SQL from the dropdown and Click on Proceed.

now you need to download the jdbc driver at below location.
cd /opt/JetBrains/TeamCity/.BuildServer/lib/jdbc
sudo wget https://jdbc.postgresql.org/download/postgresql-9.4.1212.jar

Select database type as PostgreSQL
Refresh JDBC driver
You should see like this —> Loaded PostgreSQL JDBC driver version: 9.4

Now provide the below info
Enter database Host - localhost
Enter database name - teamcity
User name - teamcity
Password - password
Click on Proceed

please wait and watch..As It may take a few mins…


Scroll down the page, Accept license agreement
Uncheck Send anonymous usage statistics
Continue button, Register as a user and create an account


No comments:

Post a Comment

AWS, Azure Cloud and DevOps Coaching Online Classes | Dec 2021 Schedule

Are you in IT? Tired of your work? Are you not able to make any good progress in your career?  Are you not having a job? Looking for a b...