Tag Archives: TeamCity

Upgrading TeamCity’s Java

Recent versions of TeamCity started to warn about Java 17 support being deprecated. Well, got to update it, right? The trouble is I forgot how to properly override the environment it runs on. It’s super easy when you know where to look…

But first, let’s start with upgrading Java to version 21. Using Ubuntu Server here.

sudo apt install wget gnupg -y
wget -qO - https://repos.azul.com/azul-repo.key | sudo gpg --dearmor -o /usr/share/keyrings/azul.gpg
echo "deb [signed-by=/usr/share/keyrings/azul.gpg] https://repos.azul.com/zulu/deb stable main" | sudo tee /etc/apt/sources.list.d/zulu.list
sudo apt update
sudo apt install zulu21-jdk -y

This should get you a fresh install of Java 21. Now, let’s make it the default – make sure to pick Java 21 from the list when prompted.


sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/zulu21/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/zulu21/bin/javac 1

sudo update-alternatives --config java
sudo update-alternatives --config javac

And that’s it! Verify it’s available by running:

java -version

Next, let’s edit TeamCity’s environment. This is the crucial part.

sudo systemctl edit teamcity-server.service

### Editing /etc/systemd/system/teamcity-server.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file

[Service]
Environment="TEAMCITY_SERVER_MEM_OPTS=-Xmx4096m"
Environment="JAVA_HOME=/usr/lib/jvm/zulu21-ca-amd64"

### Lines below this comment will be discarded

The crucial line is bold, note I used the same method to override memory allocation for Java so it’s better suited for our needs. That’s the only way I found to be actually working for TeamCity. Setting global environment variables, editing internal properties won’t work.

After editing the file make sure to reload and restart:

sudo systemctl daemon-reexec
sudo systemctl edit teamcity-server.service

That’s it! After restarting TeamCity will pick up new Java version.

TeamCity – updating Perforce SSL certificate

I recently updated SSL certificate for a Perforce server. Turns out TeamCity had issues with p4 trust not accepting the new server identity.

At this moment TeamCity’s documentation says to set the teamcity.internal.perforce.forceTrust=trueconfiguration parameter to the related project or build configuration” See for yourself at the documentation. This is simply wrong!

Thankfully TeamCity’s bug tracker has the proper solution. Turns out you have to navigate to the diagnostics tab in admin panel, go for internal properties and set it there. For reference, the link will look like this:

https://teamcity.example.com/admin/admin.html?item=diagnostics&tab=dataDir&file=config/internal.properties#!:config

That’s it! Don’t forget to disable the parameter once the new identity is picked up by TeamCity.