Build CI/CD pipelines with TeamCity

dbForge DevOps Automation for SQL Server is a solution designed for the management and deployment of changes to a SQL Server database. With dbForge DevOps Automation for SQL Server, you can automate the deployment of database changes and build a full-cycle database CI/CD pipeline using any continuous integration or continuous deployment server that supports running PowerShell. To simplify setup, dbForge DevOps Automation includes plugins for TeamCity automation servers.

dbForge DevOps Automation comes as part of the SQL Tools suite and is used in conjunction with dbForge Studio or other dbForge tools, such as Unit Test, Data Generator, Data and Schema Compare, etc. dbForge DevOps Automation allows organizing a comprehensive continuous delivery pipeline for your database.

Build a CI/CD pipeline with TeamCity

TeamCity Server is a continuous integration (CI) server, a solution that automates and manages the main team development processes (including test execution), analyzes the source code and the code changes integration, manages builds, or generates reports. TeamCity accelerates the database development process and ensures effective interaction between team members.

TeamCity allows you to set up an efficient workflow to organize the CI process.

Note

You can integrate DevOps Automation into TeamCity servers starting from version 2019.1.3.

The guide provides step-by-step procedures about how to create the TeamCity project using the dbForge DevOps Automation TeamCity plugin for SQL Server.

Prepare the environment

  • Download and install dbForge DevOps Automation for SQL Server.
  • Download and install dbForge Studio on the computer that will act as a build agent.

Install the DevOps Automation for SQL Server TeamCity plugin

1. Navigate to the TeamCity dashboard.

2. In the left navigation menu, click Admin.

3. Under Server Administration, select Plugins.

4. Click Browse plugins repository to install the plugin directly from the plugin repository, then click Proceed.

Browse the plugins repository

5. In the search box, enter dbforge, then select dbForge DevOps Automation for SQL Server.

Select the dbForge DevOps Automation for SQL Server plugin

6. On the page that appears, click Get, then select Install to [your TeamCity server URL].

Select the TeamCity server URL you want to install

7. Click Install to confirm the installation.

Confirm the installation

The plugin is now available on your TeamCity server.

8. On the Plugins page, click Enable uploaded plugins.

Alternatively, on the Plugins page, go to the External plugins section and click the arrow > Enable for the required plugin. To confirm the action, click Enable.

Enable the dbForge DevOps Automation for SQL Server plugin

Create a project

1. In the left navigation menu, click Projects.

2. On the Projects page, click Create Project.

Initiate the project creation

3. On the New Project page, specify the project name and optional description, then click Create.

Note

Project ID is automatically generated from the project name. To change the project ID, use a different name.

Specify the project name and optional description

4. On the New connection page, configure the version control system settings, then click Proceed.

Configure the version control system settings

TeamCity will check the version control system settings you’ve entered.

5. Click Create.

Verify the version control system settings

6. The Build page opens, where you can configure the project settings.

Build configurations represent CI/CD routines.

Tip

To open the build configurations page, in the left navigation menu, select Projects, then under your project, click Build. In the top right corner, use the Settings toggle to switch to editing mode.

Configure the Build configurations

The basic logic of the CI process is configured in the Build Steps section by adding various build steps. Below is a simple example of how to configure a CI process using dbForge DevOps Automation for SQL Server.

Build a database package configuration

To build a database package step, use dbForge DevOps Automation for SQL Server – Build.

This step validates the SQL scripts located in your version control system by deploying them on the specified server.

Configure the step settings

Test a database using tSQLt configuration

To create the Test step, use dbForge DevOps Automation for SQL Server – Test.

This step validates the SQL scripts by running tSQLt unit tests on the specified server.

Configure the Test step

Sync a database project configuration

To create the Sync step, use dbForge DevOps Automation for SQL Server – Sync.

This step synchronizes the generated and tested NuGet package with the specified server.

Configure the Sync step

Deploy a database

To create the Execute step, use dbForge DevOps Automation for SQL Server – Execute.

This step inserts data into the specified database by executing the INSERT statements defined in the SQL file.

Configure the Execute step

View the output result

After the project is configured, you can see the output results. By default, the project is automatically placed into the build queue after TeamCity detects new changes in the repository that is mapped to the project.

To start the project manually, click Run.

Start the project

After that, the project is added to the build queue. The build starts when a compatible agent becomes available.

Start the build process

When the project is built, its status is displayed on the dashboard.

Project status after the build process

On the Build Log tab, you can monitor the build process in real-time and view the output result. You can expand the step and view its information.

Monitor the build process

The log shows the following information: updates to source code from the version control system, creation of a temporary directory, details of each build step execution, and the publishing of artifacts.

You can also download the artifact on the Artifacts tab.

Download the artifact

Video tutorials

Watch these videos to learn how the dbForge tools can be involved in the Continuous Integration process.

  • How to import data to SQL Server database with dbForge Data Pump during the DevOps process
  • Creating database documentation during the Continuous Integration workflow
  • How to automate database schema changes for the CI process during database deployment
  • dbForge Source Control in the DevOps pipeline
  • Unit Testing for SQL Server Database in DevOps process