Sunday 2 August 2020

TeamCity Server and BulidAgent installations on Centos 7

TeamCity is a Java-based build management and continuous integration server from JetBrains.  
A Freemium license for up to 20 build configurations and 3 free Build Agent licenses is available.

Prerequisites

- Centos 7 to be installed.
- Java to be installed 
- postgresql to be installed. 

Java Installations
# sudo yum install java-1.8.0-openjdk

Postgresql Installations

Install postgresql
# sudo yum install postgresql-server postgresql-contrib

Initialize the database
# sudo postgresql-setup initdb

Start the database
# sudo systemctl start postgresql

Enable postgresql during boot
# sudo systemctl enable postgresql

TeamCity Installations
Download Teamcity tar archive from official website

mkdir /opt/teamcity
cd /opt/teamcity
wget https://download.jetbrains.com/teamcity/TeamCity-2020.1.2.tar.gz
tar -xzvf TeamCity-2020.1.2.tar.gz

Download PostgreSQL JDBC driver
We need to download PostgreSQL JDBC driver in order to use PostgreSQL database for TeamCity.

mkdir -p /opt/teamcity/TeamCity/.BuildServer/lib/jdbc/
wget https://jdbc.postgresql.org/download/postgresql-42.2.14.jar -P /opt/teamcity/TeamCity/.BuildServer/lib/jdbc/

Start service
# cd /opt/teamcity/TeamCity/bin
# ./startup.sh

Stop Service
# ./shutdown.sh

Restart Service
# ./shutdown.sh && ./startup.sh

Configure postgresql
sudo su - postgres
vim data/pg_hba.conf

Modify to md5 at the end for these below lines
# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# exit
# systemctl restart postgresql

# psql -U postgres
postgres=# CREATE USER teamcity WITH PASSWORD 'teamcity';
CREATE ROLE
postgres=# CREATE DATABASE teamcity OWNER teamcity;
CREATE DATABASE
postgres=# \q

TeamCity Web
point your browser to teamcity Server IP address and follow these below steps

Step 1: Change the Data DirectoryHere
we will change the data directory to /opt/teamcity/TeamCity/.BuildServer

Step 2: Now we have to setup database connection

Database host[:port] - localhost
Database name: xxxxxx
User name: xxxxxx
Password: xxxxx

Step 3: Accept licence

Step 4: Create Admin account

TeamCity installations has been completed. 

TeamCity BuildAgent Installations
Download Zipfile
We need to download a zip file from the teamcity server to install it on the agent. Replace the server-url with your server ip or server hostname.

mkdir /opt/teamcity
sudo unzip buildAgent.zip
sudo chmod +x bin/agent.sh
vim buildAgent.dist.properties
serverUrl=http://server-ip:8111/
cp conf/buildAgent.dist.properties conf/buildAgent.properties

Start Service
# cd /opt/teamcity/buildAgent/bin
# ./agent.sh

You would need to authorize the agent in the buildserver once its get detected. you can now start your build and work along.

No comments:

Post a Comment