TeamCity is a continuous integration software developed by JetBrains.
We will cover configuration of the TeamCity with the SQL Server, assuming that you already have TeamCity and SQL Server installed.
First we will create database and user with right permissions.
Then we will install MsSQL database driver in the TeamCity server. We will continue with migrating TeamCity’s file database into our newly created SQL database.
We will finish with registry tweak that holds the startup of TeamCity server until SQL Server is starting up.
#SQL Server Configuration# We need to create new database, let us name it TeamCityConfigration
Then we need to create new login for our database. Create login TeamCityUser and assign it to db_owner membership role of TeamCityConfiguration database.
We could also use existing one or use Windows Authentication, but do not forget about the membership role.
#TeamCity Configuration# ##TeamCity database driver## TeamCity needs external library to communicate with Microsoft SQL Server, I suggest using jtds library version 1.2.2. (I have experienced problems using the latest version of this library).
Download the archive and move it in lib directory in TeamCity Data Directory.
In TeamCity version 7+ this directory is in
So our directory must look something like:
C:\ProgramData\JetBrains\TeamCity>dir lib /s Volume in drive C has no label. Volume Serial Number is 1830-66FF Directory of C:\ProgramData\JetBrains\TeamCity\lib 13.07.2013 13:05 <DIR> . 13.07.2013 13:05 <DIR> .. 13.07.2013 17:12 <DIR> jdbc 0 File(s) 0 bytes Directory of C:\ProgramData\JetBrains\TeamCity\lib\jdbc 13.07.2013 17:12 <DIR> . 13.07.2013 17:12 <DIR> .. 22.08.2007 13:39 294.726 jtds-1.2.2.jar 1 File(s) 294.726 bytes
##Configuration file## Now we need to create configuration file for database access.
Sample configuration file is located in
Without all comments our config file should look something like this, do not forget to replace servername with your SQL Server and password.
connectionUrl=jdbc:jtds:sqlserver://sqlserver:1433;databaseName=TeamCityConfiguration connectionProperties.user=TeamCityUser connectionProperties.password=p4ssword maxConnections=50 testOnBorrow=true
Store this configuration file in tempfolder in your config file and rename it to
##Migrating to SQL Server## In command prompt, go to bin folder in TeamCity installation directory (default is C:\TeamCity).
Run the command:
C:\TeamCity\bin>maintainDB.cmd migrate -A C:\ProgramData\JetBrains\TeamCity -T C:\ProgramData\JetBrains\TeamCity\config\tempConf\database.properties
If you do not have Java installed, you can find java binaries in
##Service dependencies## Last section is relevant only if you host SQL server and TeamCity Server on same machine.
Since we set up TeamCity server to use Microsoft SQL Server database we need to have SQL Server up and running when our TeamCity starts up.
If TeamCity starts before Microsoft SQL Server is running, we get the following error when accessing TC.
To set up TeamCity depends on Microsoft SQL Server open Registry Editor (regedit.exe) with admin permissions and navigate to
If the key DependOnService is not present, right click on TeamCity folder in tree view pane and add new Multi-String Value named DependOnService. Then edit this multi-string and type your Microsoft SQL Server service name as value data. In my case this value was MSSQLSERVER.
Result can be checked using Services (
services.msc). Dependencies tab in our TeamCity Server Properties should look something like this: