I recently installed TeamCity with an external SQL Server database. I will go through the steps to install TeamCity and configure the database which was very straight forward. I mostly followed the directions found in the JetBrains documentation but added some steps where I was not familiar.

Install TeamCity

After downloading TeamCity for Windows, install it…

TeamCity Installer
TeamCity Installer
TeamCity Installing Files
TeamCity Installing Files

And complete the initialization process.

TeamCity First Install
TeamCity First Install
TeamCity Initializing
TeamCity Initializing

Shutdown the TeamCity server.

TeamCity Server Windows Service
TeamCity Server Windows Service

Set up SQL Server Database and User

Now, create a new SQL Server database with case-sensitive collation (as a short-cut choose a collation that ends with “_CS_AS”). I chose to have the TeamCity server open a connection with username and password instead of Integrated Security, so I created a new user with “dbo” rights for the TeamCity database. You can find instructions on how to use Integrated Security for SQL Server authentication here.

Install sqljdbc Driver and Set TeamCity Properties

Download the Native MS sqljdbc driver from here, unpack the driver and copy sqljdbc4.jar the the <TeamCity Data Directory>libjdbc directory. I used the default installation directory which made my TeamCity Data Directory C:ProgramDataJetBrainsTeamCity.

In the <TeamCity Data Directory>config folder, open database.mssql.properties.dist file in a text editor.

TeamCity MS SQL Properties File
TeamCity MS SQL Properties File

Edit the settings:

connectionUrl=jdbc:sqlserver://:;databaseName=
connectionProperties.user=
connectionProperties.password=

Save the file as database.properties.

TeamCity Database Properties File
TeamCity Database Properties File

Initialize the TeamCity Database

Start the TeamCity server. Open the TeamCity web page again, you’ll be prompted with an error “Database is empty or doesn’t exist”.

TeamCity Database Error
TeamCity Database Error

You will need to open the TeamCity server log file to get the Authentication Token required to initialize the database. On my computer, I found the file at C:TeamCitylogsteamcity-server.log.

TeamCity Authentication Token
TeamCity Authentication Token

Copy and paste the Authentication Token into the TeamCity web page and click the “Proceed” button at the bottom of the page.

TeamCity Create Database
TeamCity Create Database

Lastly, TeamCity will initialize a new database and server components. Once complete, TeamCity will be ready for its first use.

TeamCity Creating Database
TeamCity Creating Database