Integration of tSQLt + SSDT into Jenkins - 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.

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

Related

Jenkins MSBUILD : error MSB1008: Only one project can be specified.Switch: Files

I know there are many threads with same subject line ,but i am not getting any answer and hence putting my question here.
I am new to this and try to learn as fast as possible due to the time lines i have.
I did Jenkin setup (tried my best to do correctly in first shot)
But when ever i try to build i got following error
Started by user User 1
Building in workspace C:\Program Files (x86)\Jenkins\workspace********Service
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Done
Querying for remote changeset at '$/Reference Data Master/Development/Source/*******DataSrvices' as of 'D2017-08-24T07:21:11Z'...
Query result is: Changeset #109084 by 'user' on '2017-08-23T13:04:44Z'.
Checking if there exists a mapping for E:\MyDrive\Jenkins\workspace...yes, in workspace 'Hudson-*****Service-MASTER'.
Downloading list of workspaces from http://********:8080/tfs...
Getting version 'C109084' to 'E:\MyDrive\Jenkins\workspace'...
Finished getting version 'C109084'. Retrieved 0 resources.
Path To MSBuild.exe: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
Executing the command cmd.exe /C " chcp 1252 && C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe %workspace%\DataService.Windows\DataSrvices.sln " && exit %%ERRORLEVEL%% from C:\Program Files (x86)\Jenkins\workspace\WindowsService
[WindowsService] $ cmd.exe /C " chcp 1252 && C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe %workspace%\DataService.Windows\DataSrvices.sln " && exit %%ERRORLEVEL%%
Active code page: 1252
Microsoft (R) Build Engine version 4.0.30319.34209
[Microsoft .NET Framework, version 4.0.30319.34209]
Copyright (C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1008: Only one project can be specified.
Switch: Files
For switch syntax, type "MSBuild /help"
Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failure
Finished: FAILURE
Please find the setup i did for my first JOB in jenkins
Source COde managment : Done it for TFS
Build Trigger
Use the MSBuild plugin, and simply build your complete solution. The example in this screen shot even runs your code analysis if you like.

How to prevent TFS from moving vstest.console runsettings file

I'm testing an upgrade from TFS2015 to TFS2017 and ran into a problem when running my unit tests.
The test needs a runsettings file:
The runsettings file is physically at C:\TFS\1\s but for some reason TFS2017 is copying it to C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\tmpA03 as can be seen in the log:
2017-02-01T21:04:44.9728814Z Working folder: C:\TFS\1\s
2017-02-01T21:04:44.9728814Z Executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe "C:\TFS\1\s\SpecFlow2\bin\Debug\SpecFlowTests.dll" "C:\TFS\1\s\UnitTests\bin\Debug\UnitTests.dll" "C:\TFS\1\s\UnitTests-Analytics\bin\Debug\UnitTests-Analytics.dll" /TestCaseFilter:"TestCategory!=MultiThreadedTests&TestCategory!=Purgatory" /Settings:"C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\tmpA03.tmp" /logger:trx
My runsettings however, contains a reference to a testsettings:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<!-- 0 = As many processes as possible, limited by number of cores on machine, 1 = Sequential (1 process), 2-> Given number of processes up to limit by number of cores on machine-->
<ResultsDirectory>.\TestResults</ResultsDirectory>
<MaxCpuCount>3</MaxCpuCount>
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
<MSTest>
<SettingsFile>SingleThreaded.testsettings</SettingsFile>
<ForcedLegacyMode>true</ForcedLegacyMode>
</MSTest>
</RunSettings>
Because SingleThreaded.testsettings remains in C:\TFS\1\s, the test run fails, and even if I manually copy the file, the test still fails because some of the tests relied on the test's working directory.
How can I prevent TFS from moving my runsettings file to the temp folder and execute from the correct directory?
I couldn't reproduce your issue on my side in TFS 2017 with the setting below:
In the log, the runsetting file is gotten from C:\Agent\_work\10\s\Parallel.runsettings, so TFS won't move the setting file automatically:
2017-02-03T06:08:37.8352139Z Working folder: C:\Agent\_work\10\s
2017-02-03T06:08:37.8352139Z Executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe "C:\Agent\_work\10\s\ClassLibrary1\bin\Release\Microsoft.TeamFoundation.TestManagement.Client.dll" "C:\Agent\_work\10\s\TestCaseProject\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll" "C:\Agent\_work\10\s\TestCaseProject\bin\Release\Microsoft.TeamFoundation.TestManagement.Client.dll" "C:\Agent\_work\10\s\TestCaseProject\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll" "C:\Agent\_work\10\s\UnitTestProject1\bin\Release\Microsoft.TeamFoundation.TestManagement.Client.dll" "C:\Agent\_work\10\s\UnitTestProject1\bin\Release\UnitTestProject1.dll" /Settings:"C:\Agent\_work\10\s\Parallel.runsettings" /logger:trx
Please check whether you have mapped the runsetting file in Repository tab of the build definition. And try to clean the cache file on your build agent: C:\Users\username\AppData\Local\Microsoft\Team Foundation\7.0\Cache.
If issue persists, try to deploy a new build agent to see how it works.

TFS build does not apply the value of $(VSInstallDir) macros

I have a build-machine and I have made simple changes recently to run editbin.exe tool with LARGEADDRESSAWARE parameter right after each building. The tool is located in C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin (of course, the path can be another). And I have added new target to the build.proj file:
<Exec command=""$(VSInstallDir)\VC\bin\editbin.exe" /LARGEADDRESSAWARE "Manager.exe""/>
If I run MS Build locally on the build machine it works properly. Good! But after any checkin build is not able to be completed with the following error:
The command ""\VC\bin\editbin.exe"" exited with code 3. As I understand TFS build does not apply the value of $(VSInstallDir) macros (C:\Program Files (x86)\Microsoft Visual Studio 12.0\ in my case). Any suggesting?
To resolve the problem I did the next: In VS build config: Process->Build process parameters->5. Advances->MSBuild arguments added /p:VSInstallDir = Value

MTM run Telerik test case failed: File extension specified '.tstest' is not a valid test extension

Today we try to run telerik test case with MTM in BDT environment.
But it is failed with following error:
Error adding test case [6603] to test run: File extension specified
'.tstest' is not a valid test extension.
Actions we have done:
Install telerik runtime on Environment
Manual run test case by mstest:
"C:\Program Files (x86)\Microsoft Visual Studio
11.0\Common7\IDE\MSTest.exe" /testcontainer:.\Miscellaneous\testName.tstest
Microsoft (R) Test Execution Command Line Tool Version 11.0.51106.1
Copyright (c) Microsoft Corporation. All rights reserved.
Loading .\Miscellaneous\testName.tstest...
.\Miscellaneous\testName.tstest Could not load file or assembly
'Microsoft.VisualStudio.Shell.11.0, Version=11.0 .0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependenci es. The system cannot find the file specified.
We fix this by install telerik runtime on tfs test controller.
and do following actions:
Unregister and re-register test controller
Unregister and re-register test agent
Restart test controller machine
Then error is gone. We got the error same as run command
"C:\Program Files (x86)\Microsoft Visual Studio
11.0\Common7\IDE\MSTest.exe" testcontainer:.\Miscellaneous\testName.tstest
directly on environment.
"Could not load file or assembly 'Microsoft.VisualStudio.Shell.11.0,
Version=11.0 .0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
or one of its dependenci es"
We referred following posts to resolve the error:
http://www.telerik.com/forums/file-extension-specified-tstest-is-not-a-valid-test-extension/page/2
http://www.telerik.com/forums/file-extension-specified-aii-is-not-a-valid-test-extension
MSTest: "File extension specified '.dll' is not a valid test extension"
http://docs.telerik.com/teststudio/user-guide/command-line-test-execution/mstest.aspx

Jenkins MSTestRunner plugin is unable to launch mstest.exe

I've configured the Jenkins MSTestRunner plugin to use the following path to the MSTest executable: 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe'. However, although this path is correct, the build fails as follows:
cmd.exe /C "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe" "/resultsfile:/resultsfile testresults" /testcontainer:Project.Tests/bin/Debug/Project.Tests.dll && exit %%ERRORLEVEL%%
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
What's the issue here, I thought this would be the normal way of configuring the MSTestRunner plugin as mstest.exe is installed beneath Visual Studio, which is again typically installed under 'C:\Program Files (X86)'? How do I work around this?
Have received confirmation from the plugin author that MSTestRunner 0.2.0 doesn't handle spaces in MSTest paths. I worked around the issue by instead creating an "Execute Windows batch command" build step in Jenkins that invokes mstest.exe directly, where I've surrounded the mstest.exe path with double quotes:
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe" /testcontainer:Project.Tests\bin\Debug\Project.Tests.dll /resultsfile:testresults.trx
Found that my issue was 2 fold.
File entries are from local workspace dir
You must configure mstest in global tools and then select that instance within the build step.

Resources