Creating database packages in TeamCity
Published 07 August 2013
If you are using TeamCity as a continuous integration server, you can use the Redgate TeamCity plugin to automate the creation of database packages. To use the plugin, you must have:
- a SQL Developer Bundle or SQL Toolbelt license
- the TeamCity plugin from the SQL Automation Pack
If you're using SQL Automation pack v1.1 and later, details of how to set up a database build and create a database package are described in Using the SQL CI TeamCity plugin in SQL Automation Pack.
If you're using SQL Automation pack v1.0.4.2 and earlier, details of how to set up a database build are described in Using the SQL CI TeamCity plugin (v1.0.4.2 and earlier). You can then follow the instructions on this page to create a package.
To set up the TeamCity plugin (from SQL Automation Pack v1.0.4.2 and earlier) to create packages:
- In the TeamCity plugin, under Source-controlled database, specify the location of your database folder.
Your database folder is the folder where your database is stored in source control. In the example below, our database folder is our build VCS root in TeamCity: - Under Continuous Integration setup, select the Generate database creation script check box:
If you want to upgrade the database using static upgrade scripts, select the Generate upgrade scripts check box:
- Under Deployment Manager, select the Create a Database Package check box:
In the Package ID box, enter the name of the package you want the build to create.
You cannot upgrade databases from previous versions that use a different package name.
Packages are named with the convention <package ID>.<build number>, for example: WidgetDev.1.0.nupkg
- In the Server URL box, enter the URL for your Deployment Manager web interface, for example: http://my-server-name:82
In the DM API key box, enter the API key for your Deployment Manager user account.
For information on how to find your API key, see: Finding your API key.
Your TeamCity build is now set up to create database packages.
Publishing packages
If you are using TeamCity as a NuGet server, packages are automatically published to the TeamCity NuGet feed when the build runs.
To enable the TeamCity NuGet server:
- In TeamCity Administration, under Integrations, click NuGet Settings:
- On the NuGet Server tab, click Enable:
The URLs for your TeamCity NuGet feed are displayed. To use this feed with Deployment Manager, you need to add it as a package feed in the Deployment Manager web interface.
If you want to publish the database packages to a different feed, you need to add a NuGet Publish build step to your database build in TeamCity.
Deploying database packages
To deploy database packages, you need to specify some variables in Deployment Manager.