Jonathon

Jonathon Eve-O'Connor's Blog

Continuous Integration With TeamCity – Automating SSAS Build and Deployment

In this blog article I will be detailing how I use Team City to automate the building and deployment of SSAS projects. When looking at possible ways of doing this I wanted to make sure that it met the following requirements:

-Supported CI Deployment and building of Both Multidimensional and Tabular Projects without using a different approach for each.
-Allowed customising deployment options such as stopping the overwriting of partitions.

I tried a few different approaches but I believe this one provided the best results and met the criteria.

Prerequisites

This blog assumes the reader has first followed or is familiar with the steps outlined in the previous blogs in this series. These are available from:

http://blogs.adatis.co.uk/blogs/jeoc/archive/2014/09/10/getting-started-continuous-integration-team-city-installation-and-setup.aspx
http://blogs.adatis.co.uk/blogs/jeoc/archive/2014/09/19/configuring-team-city-to-connect-to-visual-studio.aspx
http://blogs.adatis.co.uk/blogs/jeoc/archive/2014/09/23/using-team-city-to-automate-building-and-deployment-of-database-projects.aspx
http://blogs.adatis.co.uk/blogs/jeoc/archive/2014/09/24/continuous-integration-with-team-city-automating-ssis-build-and-deployment.aspx

Overview

The technique used is to call visual studio from MSBuild to build the projects. We use a file to set the default deployment options and then make a call to the AnalysisServices Deployment Wizard in silent mode to deploy the project to the target server.

Automating the Build

To Automate the build we use an xml file in the following format

<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="Build"> <!-- Here we have a reference to the VS path to be used for the build and the relative path for the project (MD or Tabular).--> <Exec Command='"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" "./SSASTabular/SSASTabular.smproj" /Build Debug /projectconfig'/> </Target> </Project>

Add this file to the root of your project with the name SSASBuild.proj and check it in.

image

Add a build step to TFS to execute the step as per the below:

image

Ensure in Visual Studio that all the projects are set to build as without this the folders will be empty!

image

Upon running the step you should see that the project has now built and the relevant files are now contained in the \bin folder of the project, it will look a little different depending if the project is MD or Tabular.

image image

Setting the Deployment Options

One of the main requirements was to enable incremental deployments and the option for example of retaining existing partitions.
Unfortunately whilst some of the required settings are configurable from Visual Studio not all of these can be configured and when the project is built the *.deploymentoptions file which is created will always be in the same format.

As such the only option is to replace the file with one which contains the settings that we would like to use before the project is deployed.

To do this you will need to modify the format of the file so that it meets your requirments – if you need to you can run the deployment wizard using the /a answer switch which will amend the files for you based upon the options selected (see http://msdn.microsoft.com/en-us/library/ms162758.aspx for further information).

A sample file for Multidimensional deployments is included below, the method for Tabular deployments is the same although the file structure is a little different.

<DeploymentOptions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2" xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2" xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200" xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200" xmlns:ddl300="http://schemas.microsoft.com/analysisservices/2011/engine/300" xmlns:ddl300_300="http://schemas.microsoft.com/analysisservices/2011/engine/300/300" xmlns:ddl400="http://schemas.microsoft.com/analysisservices/2012/engine/400" xmlns:ddl400_400="http://schemas.microsoft.com/analysisservices/2012/engine/400/400" xmlns:dwd="http://schemas.microsoft.com/DataWarehouse/Designer/1.0"> <TransactionalDeployment>false</TransactionalDeployment> <PartitionDeployment>RetainPartitions</PartitionDeployment> <RoleDeployment>DeployRolesRetainMembers</RoleDeployment> <ProcessingOption>Default</ProcessingOption> <OutputScript></OutputScript> <ImpactAnalysisFile></ImpactAnalysisFile> <ConfigurationSettingsDeployment>Deploy</ConfigurationSettingsDeployment> <OptimizationSettingsDeployment>Deploy</OptimizationSettingsDeployment> <WriteBackTableCreation>UseExisting</WriteBackTableCreation> </DeploymentOptions>

I saved the file as SSASMDDeploy.options and added it to the project

image

Then add a new build step to Team City, this time we are going to use a simple command line based runner to replace the file which is created when the project is built with out pre-prepared one which has the options we selected as per the below:

image

The command I used in full was of the format below, you will need to amend this depending upon the environment you are working in. Note that you will need to use the %system.teamcity.build.workingDir% variable in the script as the path of the files may change.

copy %system.teamcity.build.workingDir%\ContinuousIntegrationDemo\SSASMDDeploy.options %system.teamcity.build.workingDir%\ContinuousIntegrationDemo\SSASMD\bin\SSASMD.deploymentoptions /Y

Upon executing this build step you should be able to confirm the contents of the file at build are being replaced with the ones from the project.

Automating the Deployment

We to ensure that the project will deploy to the correct target. Because these options are generally set on a user by user basis changing they are normally excluded from source control and therefore checking this in will not change the value on the build server. You could potentially change this to include the file, however it would mean that if another person working on the project changed this value then the CI build would try to build to this server.

I found the simplest way to do this was to modify the *.dwproj.user options file on the build server as this will not be subsequently overwritten

image

The final step is to automate the deployment. We do this by making a call to the AnalysisServices deployment wizard from a Command Line runner in the same manner as step 2.

The command I used was of the format

"C:\Program Files\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Microsoft.AnalysisServices.Deployment.exe"
%system.teamcity.build.workingDir%\ContinuousIntegrationDemo\SSASMD\bin\SSASMD.asdatabase /s

Upon completion you will see that the projects have been deployed to the target server specified in the user options file.

Loading