Use the TeamCity plugin

Similar documents
Using the SQL CI TeamCity plugin in SQL Automation Pack

Continuous integration for databases using Red Gate tools

1. Deployment Manager 1 documentation Requirements Getting started How Deployment Manager works

Redgate Database Lifecycle Management (DLM) vs SQL Server Data Tools (SSDT)

How to set up SQL Source Control The short guide for evaluators

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting

AD Sync Client Install Guide. Contents

MySQL On Crux Part II The GUI Client

SVN_Eclipse_at_home. 1. Download Eclipse. a. Go to: and select Eclipse IDE for Java Developers

Using SQL Developer. Oracle University and Egabi Solutions use only

Installing SQL Server Developer Last updated 8/28/2010

JetBrains TeamCity Comparison

CollabNet TeamForge 5.3 Evaluator s Guide

Sql Server 2008 R2 Default Schema Windows Grou

BLUEPRINT TEAM REPOSITORY. For Requirements Center & Requirements Center Test Definition

PASSPORTAL PLUGIN DOCUMENTATION

Outlook Integration. Installation & Configuration

Using SQLCover with SQL Release PowerShell cmdlets

Sql Server 2008 Schema Version R2 Create Database

Agenda. Why do we want to keep a DBA happy? Development process Requirements Good coding practice Source Control Unit Tests Continuous Integration

Subversion Repository Layout

If this is the first time you have run SSMS, I recommend setting up the startup options so that the environment is set up the way you want it.

Working with EGL and Subversion Using RDi with RBD

Addendum 2. Features. Addendum 2. Service Pack 2

Manual Trigger Sql Server Update Column Changed

Tasktop Sync - Cheat Sheet

8.0 Help for End Users About Jive for SharePoint System Requirements Using Jive for SharePoint... 6

Continuous Integration, Continuous Deployment and Continuous Testing by HP Codar using ALM and Jenkins

1. Prerequisites. Page 1 of 29

Configuration Guide. Requires Vorex version 3.9 or later and VSA version or later. English

How to transfer data between BPMonline 7.x environments

By defining design repositories in this centralized fashion, an oganization can fully control which repositories its designers can access and use.

One Schema In Sql Server 2005 Management >>>CLICK HERE<<<

Administering isupport

<Partner Name> RSA NETWITNESS Security Operations Implementation Guide. Swimlane 2.x. <Partner Product>

Alter Changing Default Schema Sql Server Management Studio

Subversion was not there a minute ago. Then I went through a couple of menus and eventually it showed up. Why is it there sometimes and sometimes not?

CASE STUDY FINANCE. ABSA Bank Introducing database automation with SQL Toolbelt

Studio 2008 Change Table

Software Center Update Publisher (SCUP) / Software Update Point (SUP) APSCNLAN Support

Managed Projects. Modified by Jason Howie on 31-May-2017

CollabNet Desktop - Microsoft Windows Edition

Application Deployment System Guide Version 8.0 October 14, 2013

PMAPS WebPro Installed Technical Requirements Checklist

Apache Subversion Tutorial

HR-Lite Database & Web Service Setup Guide

Getting Started with the Ed-Fi ODS and Ed-Fi ODS API

DOCUMENT REVISION HISTORY

MobileFast SyncStudio. A Complete Mobile Database Synchronization Solution. Quick-Start Manual. Release 1.61, May 2014

Customer Access Instructions

2012 Peer Small Business Data

ECM-VNA Convergence Connector

Archivists Toolkit Internal Database

SAP HANA Authorization (HA2)

DBXL AZURE INSTALLATION GUIDE

Preupgrade. Preupgrade overview

Generate Xml Instance From Schema Visual >>>CLICK HERE<<<

SpiraTeam Build Server Integration Guide Inflectra Corporation

Sql Server 'create Schema' Must Be The First Statement In A Query Batch

DB2 for z/os Stored Procedure support in Data Server Manager

Contents Getting Started... 3 About Scribe Online and Connectors... 3 Scribe Online Services... 3 CDK Components... 3 Audience... 4 Prerequisites...

Using Assembla in PracTEX Production

SpiraTeam IDE Integration Guide Inflectra Corporation

Database Table Schema Sql Server 2008 R2 Management Studio Open

Installation of Microsoft SQL Server 2012 Setup MwPharm++ database

NETWRIX ACTIVE DIRECTORY CHANGE REPORTER

Tasktop Sync - Quick Start Guide. Tasktop Sync - Quick Start Guide

Alfresco Content Services 5.2. Getting Started Guide

Manual Backup Sql Server Express 2008 Schedule Database Sql Agent

Table of Contents. Abstract

PORTALS, DASHBOARDS AND WIDGETS DIGITAL EXPERIENCE MANAGER 7.2

APAR PO06620 Installation Instructions

Partner Integration Portal (PIP) Installation Guide

Release notes for version 3.7.1

Table of Contents. Knowledge Center -

Application Notes for Installing and Configuring Avaya Control Manager Enterprise Edition in a High Availability mode.

IQSweb Reference B. SQL Server 2008 R2 and Express Installation Instructions

Upgrade Guide. Version 8.2 May 2, For the most recent version of this document, visit our documentation website.

Installation Guide. May vovici.com. Vovici Enterprise Version 6.1. Feedback that drives vision.

2. PRTG LabTech Plugin Configuration and Usage

Test Automation Integration with Test Management QAComplete

Getting Started Guide

You create project parameters to store the username and password that are used to access the FTP site.

Database Continuous Delivery & Your Salvation!

Data Sources. Data Sources Page

EasyLobby Database Setup EasyLobby Family of Products Version 10.0

Connect with Remedy: SmartIT: Social Event Manager Webinar Q&A

The following sections describe the various menu options.

Sherlock Tutorial ODB++ Project Creation

Create Schema In Sql Server 2005 Management Studio

BEAAquaLogic Enterprise Repository. IBM Rational ClearCase and IBM Rational ClearQuest Integration Guide

About using Microsoft Query to retrieve external data

New World ERP-eSuite

8.0 Help for Community Managers About Jive for Google Docs...4. System Requirements & Best Practices... 5

Early Data Analyzer Web User Guide

Published on Online Documentation for Altium Products (

SQL Server Deployment Installation Manual. Call a Hygiena representative for more information or support

Securing Design Source Inside a Design Repository

Table of Contents. Concepts

CircuitPython with Jupyter Notebooks

Transcription:

Use the TeamCity plugin This example shows you how use the DLM Automation TeamCity plugin to validate, test and sync your development schema. In this example, you'll use TeamCity and DLM Automation's TeamCity plugin build runners to: build a database package test the package sync the package to a CI environment publish the package to a NuGet feed When you've finished, TeamCity will automatically trigger a continuous integration process every time a change is checked into version control. Before you start Get a copy of your database scripts folder and place it into source control. You can either: On your build server: use your database source controlled using SQL Source Control generate a folder from an existing database using SQL Compare and place that under source control download and unzip WidgetShop.zip and place that under source control Make sure you have JetBrains TeamCity version 7 or later. We've tested this example against version 9. If you didn't previously have an installation, this automatically installs a default build agent. From the Redgate DLM Automation add-ons page, download the DLM Automation TeamCity plugin and copy to the TeamCity data directory plugin folder. See Setting up the TeamCity plugin. On your build agent: Install Redgate DLM Automation by d ownloading the SQL Toolbelt installer from the Redgate website and following the instructions. Create a TeamCity project You can add the build step to an existing project / build configuration, but for the purposes of this example we'll create a new project to work with. In TeamCity Administration, under Projects, click Create project: On the Create New Project page, add WidgetShop as the name for the project. The Project ID is created automatically: 4. Click Create. Under Build Configurations, click Create build configuration:

5. On the Create Build Configuration page, add WidgetDevelopment as the build name: 6. Click Create. Link the database to TeamCity Configure the TeamCity VCS settings so it knows which network folder to monitor for changes. Here we link to an SVN repository, but you can use whichever VCS you set up earlier: On the VCS Roots page, from the Type of VCS drop-down list, select Subversion. Under VCS Root Name and ID, in the VCS root name field, enter a name - e.g. SVN WidgetShop - as the unique name for this root. Under SVN Connection Settings, in the URL field, enter your repository URL - e.g. file:///z:/widgetshop/. This was the Database repository URL you entered when you linked the database to source control, if you are using SQL Source Control.

If authentication is required for your source control server, you must specify a username and password. 4. Click Test connection. TeamCity checks that it can connect to the source control location. Once the 'connection successful' message is displayed, close it and click Create. The VCS settings are complete. Continuous integration These sections explain how to add automated steps to: build a package every time a change is checked into source control run tsqlt tests against the package

sync the package to a CI environment publish the package to a NuGet feed Build a package In this section you'll use the DLM Automation TeamCity plugin to: add a build step to validate the SQL creation script and create a NuGet package add a VCS trigger to force a build every time a change is checked into version control trigger a build to test this step Add a build step You'll add the build step using one of Redgate's build runners for TeamCity. A build runner allows a specific third party build tool, such as DLM Automation, to integrate with TeamCity. This example uses the DLM Automation Build runner that's part of Redgate's DLM Automation TeamCity plugin. It defines how to run the build and handle the output. For more information on build runners, see Configuring Build Steps (JetBrains documentation). When the build step validates the creation script, DLM Automation creates a temporary version of the database using LocalDB. This database is dropped once the build is complete. From the Build Configuration Settings menu, select Build Steps. Click Add build step: From the Runner type drop-down, select Redgate DLM Automation Build: 4. 5. Under Source-controlled database, leave the Database folder is my build VCS root option selected. We've already configured the VCS root as our database location. If you're using the step as part of a larger project, you can change this and specify where your database folder is. Under Output package, at the Package ID field, enter a name, e.g. WidgetShopLatest. This is the name of the NuGet package you'll create. The name must be unique and can't contain spaces. When you're thinking of a package name to use in your own environment, remember that it's going to be deployed to other environments. A generic name that describes what you're deploying is better than one that's specific to the build step or the database itself. For example, if your database is called Development, this wouldn't make sense as a package name deployed to your production database.

6. Under Temporary database server, select SQL LocalDB. DLM Automation uses LocalDB to recreate and validate a temporary version of your database. This database is dropped once the build is complete. LocalDB will work for this example, but if you have features in your database that are not supported by LocalDB - like full text indexing - you will need to specify an actual SQL Server instance that the build system can talk to and create a temporary database on. 7. If you're using Redgate's DLM Dashboard (version 4.4.313 or later), DLM Automation can send schema information to it every time the build step runs. Under DLM Dashboard integration: a. Enable the Send schema information to DLM Dashboard check box. b. Enter the name or IP address of the machine hosting the DLM Dashboard. c. Enter the DLM Dashboard port number. The default port is 19528. Once you deploy changes (for example, by running the sync step), DLM Dashboard: recognizes the deployed schema from the information DLM Automation sent during the build step adds the schema to its list of recognized schemas, with the name <packageid-packageversion>, for example, WidgetShop0 labels the schema with the DLM Automation icon labels the schema as an update, not drift 8. For more information about how DLM Automation works with DLM Dashboard, see DLM Automation integration (DLM Dashboard documentation). DLM Automation can include SQL Doc database documentation in the NuGet package that it builds. To select this option, under Databas e documentation, click Include database documentation. Including database documentation will increase the size of the NuGet package and the time it takes to build, particularly for large databases. The documentation is stored in db > docs > main.html in the NuGet package. If you're using DLM Dashboard version 6.3 or later and have set up DLM Dashboard integration, you can also view the documentation directly from DLM Dashboard. See DLM Automation integration (DLM Dashboard documentation) for more details. For help understanding SQL Doc documentation, see What's in the documentation? 9. Click Save. Add a VCS trigger Add a trigger that'll force a build every time a change is checked into version control: From the Build Configuration Settings menu, select Triggers: On the Triggers page, click Add new trigger and select VCS Trigger from the drop-down:

Click Save. TeamCity will now run a build when you check in a change to your WidgetDevelopment database. Trigger a build To run a build either make a change in the source control repository or click Run. To display the build status, click Projects: 4. To show a summary of the log messages printed by the build, move your cursor over the Success drop-down button, and then click Build log. To view the NuGet package, click Artifacts: The build artifact is the name TeamCity gives to the output of a build step. In this example, the NuGet package is the artifact, and it's stored on TeamCity's server until we're ready to deploy it.

Test the package In this section you'll: check a SQL Data Generator file into version control. This will generate meaningful test data for the database add a test step so that every time there's a new build of your database, DLM Automation will create a temporary version and run tsqlt tests against it trigger a build to test this step The WidgetDevelopment database used by this example already has tsqlt installed. If you're setting this up in your own environment, you'll need to install it. For more information, see SQL Test. Check the SQL Data Generator file into version control We've provided a SQL Data Generator file that's already configured to generate data that's meaningful to the rows, columns and tables in the Wid getdevelopment database. You can extract this file from the WidgetDevelopmentDatabaseCIDemo.zip file. If you've been using a different database but would like to use our pregenerated file for this step, either run WidgetDevelopment.sql from the above file and link it to your VCS with SQL Source Control, or get the scripts folder straight out of WidgetShop.zip and put that directly into your VCS. Otherwise you'll need to create a new SQL Data Generator project file for your own database using SQL Data Generator. If you already have WidgetDevelopment in source control and are using SVN with TortoiseSVN: Using Windows Explorer, copy the WidgetTestData.sqlgen file from WidgetDevelopmentDatabaseCIDemo > WidgetShop > Database to the location you added the database to source control. Right-click on the WidgetTestData.sqlgen file and select TortoiseSVN > Add. Right-click again and select SVN Commit. 4. At the Commit dialog, add a comment, for example, sqlgen file added. Click OK. Add a test step You can run different types of tsqlt tests, such as static analysis, unit or integration tests, against your temporary database. If you are using your own database you will need to set up some of these. SQL Test makes it easy for you to add the SQL Cop suite of static analysis tests if you would like some examples. The database schema for WidgetDevelopment already includes four basic SQL Cop tests that will run against the temporary database and check for: 4. procedures named SP_ procedures using dynamic SQL without sp_executesql procedures with @@Identity procedures with SET ROWCOUNT There's also a unit test in the schema that checks email addresses in the Contacts column. Once the tests are complete, DLM Automation generates test reports for review. The temporary database is then dropped. To create the test step: On the Build Steps page, click Edit on your build step (or create a new build step if necessary - see Build a package above) At the Run tests option, leave Run every test selected. At the Generate test data option, select the Populate the database with data before testing check box, and enter the path to the Widg ettestdata.sqlgen file (or your own.sqlgen project file). This must be relative to the VCS Root folder. In this example, the path is file:///z:/widgetshop/, so you just need to enter WidgetTestData.sqlgen. Click Save. Trigger a build Make a change to the database to trigger the build and test steps automatically: Check in a change to the database with SQL Source Control or your source control system. To display the build status, in TeamCity click Projects > YourProjectName (e.g. WidgetShop). Once the build step is complete, the test step starts automatically. Once the steps are complete, click Tests passed: 5:

4. Click the Tests tab. Details of the completed tests are displayed: To see more details about a specific test, or for troubleshooting a failed test, move your cursor over the drop-down button and select Show in build log. Sync the package to a CI environment Once your database has been through an initial test phase, it's good practice to run system, acceptance or smoke tests against it in an environment that simulates production. We'll called this the CI database, although it's sometimes called staging or preproduction. In this section you'll: create a CI database add a sync step so that every time your database has been built and tested, DLM Automation will synchronize it to your CI database trigger a build to test this step Create a CI database Create a blank database as your CI database: Open SQL Server Management Studio (SSMS). Click New Query. Execute the following SQL query to create e.g. the WidgetCI database: CREATE DATABASE WidgetCI GO USE WidgetCI GO It doesn't need to be checked into source control because it'll be updated automatically every time a change is made to the development (e.g. WidgetDevelopment) database. Add a sync step

Add a sync step in TeamCity: On the Build Steps page, click Add build step. From the Runner type drop-down, select Redgate DLM Automation Sync. Under Output package, at the Package ID text box, enter your package name, e.g. WidgetShopLatest. This is the name of the NuGet package your build step created and your tests have tested. 4. Under Database server, enter the name of the target server and database you want to update. In this example, we're updating the Widget CI database using Windows authentication. 5. Click Save. Trigger a build Check in a change to your database to trigger a build. Once the build and test steps are complete, open SSMS to verify that the WidgetCI database has been synchronized with the contents of WidgetDevelopment: The WidgetCI database is now up to date with the latest version in source control. At this point, you could run additional tests against it. Publish the package to a NuGet feed Now that you've finished testing, you can publish the package to a NuGet feed. You can then use Octopus Deploy with DLM Automation to manage deployments. We'll use TeamCity as a NuGet server to save you having to set up your own repository. For more details, see Using TeamCity as a NuGet Server (TeamCity documentation). In this section you'll: enable the TeamCity NuGet server so you can publish the package to its NuGet feed trigger a build to test this step If you're using a different release management tool, check the help documentation provided by that tool vendor.

Enable the TeamCity NuGet server In TeamCity Administration, under Integrations, click NuGet: On the NuGet Server tab, click Enable: Trigger a build Trigger a build to publish the package to the NuGet feed automatically.