April 26, 2025

How to Install TeamCity on Ubuntu — Step-by-Step Guide 2025

ubuntu

TeamCity is a powerful continuous integration (CI) and continuous delivery (CD) server developed by JetBrains. It enables software development teams to automate the process of building, testing, and deploying applications. In this detailed guide, we’ll walk you through installing TeamCity on an Ubuntu server.


Prerequisites

Before we begin, ensure the following:

  • Ubuntu 20.04 LTS or higher
  • A non-root user with sudo privileges
  • Java 11 or higher
  • Minimum 2 GB RAM and 1 CPU core (4 GB RAM recommended)
  • At least 1 GB of disk space for the TeamCity server

Step 1: Update System Packages

Start by updating your package index:

sudo apt update && sudo apt upgrade -y

Step 2: Install Java

TeamCity requires Java to run. We’ll install OpenJDK 17.

sudo apt install openjdk-17-jdk -y

Verify Java installation:

java -version

You should see output similar to:

openjdk version "17.0.x" ...

Step 3: Create TeamCity User

It’s a good practice to run TeamCity under its own user.

sudo useradd -m -s /bin/bash teamcity

Step 4: Download and Extract TeamCity

Navigate to the TeamCity downloads page and copy the latest .tar.gz link.

cd /opt
sudo wget https://download.jetbrains.com/teamcity/TeamCity-2023.11.2.tar.gz
sudo tar -xzf TeamCity-2023.11.2.tar.gz
sudo mv TeamCity teamcity
sudo chown -R teamcity:teamcity /opt/teamcity

Step 5: Configure Database (Optional but Recommended)

For production, it’s better to use an external database like PostgreSQL or MySQL. Here, we’ll use PostgreSQL.

Install PostgreSQL:

sudo apt install postgresql postgresql-contrib -y

Create a database and user:

sudo -u postgres psql
CREATE DATABASE teamcity;
CREATE USER teamcity_user WITH PASSWORD 'securepassword';
GRANT ALL PRIVILEGES ON DATABASE teamcity TO teamcity_user;
\q

Download JDBC Driver:

cd /opt/teamcity/lib/jdbc/
sudo wget https://jdbc.postgresql.org/download/postgresql-42.6.0.jar

Step 6: Start TeamCity Server

Switch to the teamcity user and start the server:

sudo su - teamcity
cd /opt/teamcity/bin
./runAll.sh start

TeamCity starts on port 8111. Open your browser and go to:

http://your_server_ip:8111

Step 7: Complete TeamCity Setup via Web UI

  1. Choose Data Directory: You can leave the default.
  2. Select Database: Choose PostgreSQL and enter the connection info:
    • Host: localhost
    • Port: 5432
    • DB: teamcity
    • User: teamcity_user
    • Password: securepassword
  3. Wait for TeamCity to initialize the database.
  4. Create an administrator account.

Step 8: Setup as a Service (Optional)

To ensure TeamCity starts on boot, create a systemd service:

sudo nano /etc/systemd/system/teamcity.service

Paste the following content:

[Unit]
Description=TeamCity Server
After=network.target

[Service]
Type=forking
User=teamcity
ExecStart=/opt/teamcity/bin/runAll.sh start
ExecStop=/opt/teamcity/bin/runAll.sh stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Enable and start the service:

sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable teamcity
sudo systemctl start teamcity

Check the status:

sudo systemctl status teamcity

Step 9: Open Required Ports

Allow port 8111 through the firewall:

sudo ufw allow 8111
sudo ufw reload

Step 10: Install Build Agent (Optional)

You can install a TeamCity build agent on the same or different machine. Download it from the server UI under Agents tab.

Follow the instructions to configure the agent to connect back to the server.


Final Thoughts

Installing TeamCity on Ubuntu is straightforward if you follow the steps carefully. With CI/CD becoming a cornerstone of modern DevOps practices, having TeamCity up and running can significantly improve your build and deployment pipelines. Don’t forget to secure your server with proper firewall rules and regularly update your TeamCity version.

Have any questions or stuck somewhere? Let us know in the comments!


Follow me in Linkedin

Amritpal

I’m the owner of “DevOpsTechy.online” and been in the industry for almost 6+ years. What I’ve noticed particularly about the industry is that it reacts slowly to the rapidly changing world of technology. I’ve done my best to introduce new technology into the community with the hopes that more technology can be utilized to serve our customers. I’m going to educate and at times demonstrate that technology can help businesses innovate and thrive. Throwing in a little bit of fun and entertainment couldn’t hurt right?

Amritpal

I’m the owner of “DevOpsTechy.online” and been in the industry for almost 6+ years. What I’ve noticed particularly about the industry is that it reacts slowly to the rapidly changing world of technology. I’ve done my best to introduce new technology into the community with the hopes that more technology can be utilized to serve our customers. I’m going to educate and at times demonstrate that technology can help businesses innovate and thrive. Throwing in a little bit of fun and entertainment couldn’t hurt right?

View all posts by Amritpal →

Leave a Reply

Your email address will not be published. Required fields are marked *