Search code examples
jenkinssql-server-data-toolstsqltssdt-2019

Integration of tSQLt + SSDT into Jenkins


I am using SQL Server 2017 and Visual Studio 2019 Community edition.

I have created my first SSDT project and configured it in Jenkins and I am facing issues while deploying it before running my tSQLt test cases.

Please refer to the link which I used to configure everything:

https://the.agilesql.club/2017/03/sql-server-continuous-deployment-in-a-box/#comment-4976546606

PS: Have made changes in related ps files for paths of msbuild and other related files as I am using SSDT and Sql server recent versions and above link shows older versions.

Error

I got succeed to build my ssdt project in jenkins but when it tries to run "DeployDacpac.ps1" in "Unit Tests" step it shows success in pipeline steps but actually script shows error like :

C:\Program Files (x86)\Jenkins\workspace\Test12_master>powershell.exe -ExecutionPolicy RemoteSigned -File "C:\Program Files (x86)\Jenkins\workspace\Test12_master/Deploy/DeployDacpac.ps1" -projectPath "C:\Program Files (x86)\Jenkins\workspace\Test12_master" -dacpac "C:\Program Files (x86)\Jenkins\workspace\Test12_master/bin/Debug/DatabaseUT.dacpac" -publishProfile "C:\Program Files (x86)\Jenkins\workspace\Test12_master/DatabaseUT.publishprofile.xml"

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Data.Tools.Utilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.Data.Tools.Schema.CommandLineTool.Program.Main(String[] args)

Update: Now after changing path of sqlpackage.exe from my local folder to visual studio...\SQLDB\DAC\140\sqlpackage.exe" deployment works fine. But it shows that tSQLt unit tests step run successfully. Its not showing proper message any test case failed or passed.

Here is some ending result lines from unit test run step:

"... Installing package 'AgileSQLClub.tSQLtTestAdapter' to 'C:\Program Files (x86)\Jenkins\workspace\Test17_master\Lib'. CACHE https://api.nuget.org/v3/registration5-gz-semver2/agilesqlclub.tsqlttestadapter/index.json Package "AgileSQLClub.tSQLtTestAdapter.0.59.0" is already installed. Microsoft (R) Test Execution Command Line Tool Version 16.6.0 Copyright (c) Microsoft Corporation. All rights reserved. Starting test execution, please wait... A total of 158 test files matched the specified pattern."

It consideres all sps including tSQLt sps above in 158. But no result mentions if any unit test passed or failed.

Please guide.


Solution

  • Instead of SSDT project, I am using batch command to run tsqlt test cases through jenkins. i.e. sqlcmd. So no need to dig more