Upgrade TeamCity to a new version

Create a backup of the database and the server before the upgrade

  1. Place an instance with a maintenance screen in the load balancer,
  2. Remove the TeamCity server from the load balancer,
  3. Disable the Chef-Client scheduled task and Chef-Client service to make sure Chef does not alter the server during the upgrade.
  4. Disable the authorized agents to stop them picking new jobs.
  5. Stop the TeamCity process on the server,
    1. If TeamCity is started by a scheduled task at startup
      1. Disable the “teamcityserver” scheduled task in the Task Scheduler,
      2. Stop the “Java(TM) Platform SE binary” process in Task Manager.
    2. If TeamCity is running as a Windows Service
      1. Stop and disable the “TeamCity” service.
  6. Save a copy of the TeamCity configuration directories to the data drive and an outside location
    1. D:\TeamCity\conf to D:\backup\conf – TODAY’S_DATE
    2. D:\ProgramData\JetBrains\TeamCity\config to D:\backup\config – TODAY’S_DATE
      Some file names in the D:\ProgramData\JetBrains\TeamCity\config\projects directory can be very long, so save the backup close to the root of the drive.
  7. Create a backup image of your server,
    1. Select the server in the EC2 server list
    2. Click the Actions button and select Image, Create Image
    3. If you want to keep the server running, check the No reboot check box, but the file system integrity is not guaranteed.
  8. Create a backup snapshot of your database,
    1. In the RDS instance list select the database instance,
    2. Click the Instance actions button and select Take snapshot
  9. If the image creation did not restart the server, restart the box to make sure no processes hold files in the TeamCity install folder.


Upgrade TeamCity from the web user interface

  1. Remote into the TeamCity server
  2. Start the TeamCity service
  3. In a web browser navigate to http://localhost:8111/
  4. Log into TeamCity as an administrator
  5. Click the Administration link in the upper right corner
  6. Select the Updates link on the left under System Administration
  7. Click the Check for updates button
  8. On the Updates page click the Download update button
  9. TeamCity will start the download of the installer
  10. Click the Update button to start the update process
  11. Click the Update button to update the server
  12. Click the I’m a server administrator… link to allow the database upgrade. If TeamCity asks for the Authentication Token, find it at the end of the D:\TeamCity\logs\teamcity-server.log file
  13. Leave the Backup… checkbox checked and click the Upgrade button
  14. When the update suceeds, the Updates page appears again
  15. In case of the automatic update failure follow the instructions at https://confluence.jetbrains.com/display/TCD10/Upgrade#Upgrade-AutomaticUpdate


To install an earlier version of TeamCity, manually download the installer

  1. Turn off the Internet Explorer Enhanced Security Configuration,
  2. Enable file download on your server. Set the Internet Explorer security level to Medium-high
  3. Download the TeamCity server installer
    1. To download the latest TeamCity version navigate to
    2. For earlier versions go to https://confluence.jetbrains.com/display/TW/Previous+Releases+Downloads

Install the new version of TeamCity server

  1. Execute the downloaded installer from the Downloads folder,
  2. If the current version of TeamCity is not on the C drive, make sure you select the correct drive,
  3. JetBrains recommends the uninstallation of the previous version of TeamCity,
  4. JetBrains does not recommend the agent instalation on the server, disable it,
  5. Run TeamCity under the SYSTEM account,
  6. To start TeamCity, leave the checkbox selected,
  7. TeamCity can automatically open the web user interface in your default browser,

TeamCity configuration

When you first try to launch the TeamCity server on a 64 bit Windows, you may get the message:

This page can’t be displayed
•Make sure the web address http://localhost:8111 is correct.
•Look for the page with your search engine.
•Refresh the page in a few minutes.

The D:\TeamCity\logs\teamcity-winservice.log file also contains the error message:

ProcessCommand [Info] Process exited with code: 1
console [Info] Error: Could not create the Java Virtual Machine.
console [Info] Error: A fatal exception has occurred. Program will exit.
console [Info] Invalid maximum heap size: -Xmx10g
console [Info] The specified size exceeds the maximum representable size.
ServiceExecuteProcessTask [Error] Service process exited without service stop request

Follow the instructions below to switch to 64 Java.

TeamCity on 64-bit Java

The TeamCity installer also installs the 32-bit version of the Java Runtime Environment (JRE) in the “D:\TeamCity\jre” folder. To use the 64 bit Java, test if your server has 64-bit Java installed:

  1. Open a command window and execute,
    java.exe -d64 -version
  2. The installed Java is 32 bit if you get the error message:
    Error: This Java instance does not support a 64-bit JVM.
    Please install the desired version.

Switch to 64-bit Java

  1. Stop the TeamCity Windows Service,
  2. Rename the D:\TeamCity\jre to jre_32bit, so TeamCity will not find it anymore,
  3. If you have not specified the memory settings in the Set the TEAMCITY_SERVER_MEM_OPTS environment variable based on the physical memory size of your server and the estimated usage
    1. Start Windows Explorer
    2. Right-click This PC and select Properties
    3. Select Advanced system settings
    4. Click the Environment Variables… button
    5. In the System Variables section select TEAMCITY_SERVER_MEM_OPTS
    6. Set the value based on the expected server load:
      1. minimum setting for 32-bit and 64-bit java:
      2. recommended setting for medium 64-bit server and maximum for 32-bit server:
      3. recommended setting for large server (64-bit java only):
        -Xmx4g -XX:ReservedCodeCacheSize=350m
      4. maximum settings for large-scale server use (64-bit java only):
        -Xmx10g -XX:ReservedCodeCacheSize=512m

Source: https://confluence.jetbrains.com/display/TCD10/Installing+and+Configuring+the+TeamCity+Server#InstallingandConfiguringtheTeamCityServer-SettingUpMemorysettingsforTeamCityServer


Finish the TeamCity upgrade

    1. Remote into the TeamCity server,
    2. Start the TeamCity Server Windows service,
    3. Open a web browser and navigate to http://localhost:8111/
    4. Click the I’m a server administrator… link,
    5. Find the authentication token at the end of the D:\TeamCity\logs\teamcity-server.log file
    6. Enter it into the textbox
    7. Allow TeamCity to make a backup of your current data,
    8. TeamCity will display the progress of the backup process.
    9. TeamCity will automatically start the server initialization.
    10. And finally, will display the login page.
  1. Navigate to the Agents page.

    First, all agents will be on the Disconnected tab. The agents will upgrade themselves to the same version as the server, and one-by-one will appear on the Connected tab.

In case of the automatic update failure follow the instructions at https://confluence.jetbrains.com/display/TCD10/Upgrade#Upgrade-AutomaticUpdate


Disaster recovery

If for some reason the server does not work after the upgrade, you can restore the database and the server from the backups you made before the upgrade.

Rebuild the environment

  1. Terminate the failed TeamCity server
  2. Restore the database from the backup snapshot
  3. Launch a new server instance from the backup server image

Make sure that the TeamCity process is not running on the restored server

When the server has started, remote into it.

  1. Check if the TeamCity process has been stopped:
    1. If TeamCity is started by a scheduled task at startup
      1. Disable the “teamcityserver” scheduled task in the Task Scheduler,
      2. Stop the “Java(TM) Platform SE binary” process in Task Manager.
    2. If TeamCity is running as a Windows Service
      1. Stop and disable the “TeamCity” service.

Update the server configuration

TeamCity stores the address of the database and the IP address of the server in config files. To be able to use the restored server, make the following changes:

Update the database address

  1. Update the database address in the connectionUrl line of D:\ProgramData\JetBrains\TeamCity\config\database.properties

Update the IP address of the server

  1. Update the server IP address in the server rootURL element of D:\ProgramData\JetBrains\TeamCity\config\main-config.xml

Start TeamCity

  1. Start the TeamCity service or scheduled task

Test the TeamCity server

  1. Open a web browser on the server and navigate to http://localhost:8111/

Load Balancer

  1. Attach the server to the load balancer

Leave a comment

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