There is a problem in the Task tsSQLt Tests task (it can reproduce this problem).
Source code (you can find it in the working folder of the agent, for example: _work / _task / RunDatabaseTestsxxx):
RunDatabaseTests.ps1:
[CmdletBinding(DefaultParameterSetName = 'None')]
param()
$global:ErrorActionPreference = 'Stop'
Import-Module -Name "$PSScriptRoot\ps_modules\TaskHelpers"
[string]$outputPath = Get-VstsInput -Name OutputPath
[string]$databaseServer = Get-VstsInput -Name DatabaseServer
[string]$databaseName = Get-VstsInput -Name DatabaseName
[bool]$useWindowsAuth = Get-VstsInput -Name UseWindowsAuth -AsBool
[string]$databaseUserName = Get-VstsInput -Name DatabaseUserName
[string]$databasePassword = Get-VstsInput -Name DatabasePassword
Write-VstsTaskVerbose -Message 'Ensuring the path to sqlcmd is present in env:PATH'
Initialize-SqlCmdInPathEnvironmentVariable
[string]$sourcesDirectory = Get-VstsTaskVariable -Name 'Build.SourcesDirectory'
if(!$sourcesDirectory)
{
Write-VstsTaskVerbose -Message 'Build.SourcesDirectory was not found as a VSTS Task variable'
Write-VstsTaskVerbose -Message 'Looking for Agent.ReleaseDirectory to use as source directory instead'
$sourcesDirectory = Get-VstsTaskVariable -Name 'Agent.ReleaseDirectory'
}
if(!$sourcesDirectory)
{
$msg = 'No source directory found'
Exit-WithError $msg
}
Write-VstsTaskVerbose -Message 'Source directory found'
Write-VstsTaskDebug -Message "buildSourcesDirectory = $buildSourcesDirectory"
if ([System.IO.Path]::IsPathRooted($outputPath) -eq $False)
{
$outputPath = Join-Path $sourcesDirectory $outputPath
}
Write-VstsTaskDebug -Message "OutputPath(absolute) = $outputPath"
if ($useWindowsAuth -eq $True) {
Write-VstsTaskVerbose -Message 'Starting sqlcmd with Windows Authentication'
Invoke-VstsTool -FileName 'sqlcmd.exe' -Arguments "-S $databaseServer -d $databaseName -i 'RunTests.sql'"
Invoke-VstsTool -FileName 'sqlcmd.exe' -Arguments "-S $databaseServer -d $databaseName -i 'OutputResults.sql' -o $outputPath"
}
else {
Write-VstsTaskVerbose -Message 'Starting sqlcmd with SQL Authentication'
Invoke-VstsTool -FileName 'sqlcmd.exe' -Arguments "-S $databaseServer -d $databaseName -U $databaseUserName -P $databasePassword -i 'RunTests.sql'"
Invoke-VstsTool -FileName 'sqlcmd.exe' -Arguments "-S $databaseServer -d $databaseName -U $databaseUserName -P $databasePassword -i 'OutputResults.sql' -o $outputPath"
}
$x = Get-Content $outputPath -Raw
$x.Replace("`r`n", "") > $outputPath
RunTests.sql:
EXEC [tSQLt].[RunAll];
OutputResults.sql:
:XML ON
EXEC [tSQLt].[XmlResultFormatter];
, "sqlcmd.exe" -S v-tinmo-12r2 -d ReadyRollDemo2 -U starain -P User@123 -i RunTests.sql
( "RunTests.sql", ))
, , sqlcmd.exe , " tSQLt Tests", /.