Upgrade TeamCity to version 2017

Upgrade TeamCity to version 2017

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

  1. Disable the Chef-Client scheduled task and Chef-Client service to make sure Chef does not alter the server during the upgrade.
  2. Disable the authorized agents to stop them picking new jobs.
  3. 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.
  4. Save a copy of the TeamCity configuration directories to the data drive and an outside location
    1. D:\TeamCity\conf
    2. D:\ProgramData\JetBrains\TeamCity\config
      Some file names in the D:\ProgramData\JetBrains\TeamCity\config\projects directory can be very long, so save the backup first in the root of the data drive
  5. Create a backup image of your server,
  6. Create a backup snapshot of your database,
  7. If the image creation did not restart the server, restart the box to make sure no processes hold files in the TeamCity install folder.

Download the TeamCity installer

  1. Enable file download on your server. Set the Internet Explorer security level to Medium-high
  2. Download the TeamCity server installer
    1. To download the latest TeamCity version navigate to
      http://www.jetbrains.com/teamcity/download/
    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. If you want 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 Envirnment 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:
        -Xmx750m
      2. recommended setting for medium 64-bit server and maximum for 32-bit server:
        -Xmx1024m
      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. Start the TeamCity Server Windows service,
  2. Open a web browser and navigate to http://localhost:8111/
  3. Click the I’m a server administrator… link,
  4. Find the authentication token at the end of the D:\TeamCity\logs\teamcity-server.log file
  5. Enter it into the textbox
  6. Allow TeamCity to make a backup of your current data,
  7. TeamCity will display the progress of the backup process.
  8. TeamCity will automatically start the server initialization.
  9. And finally, will display the login page.

 

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 ben 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 Reply