2017-12-19 09:51:24 +03:00
Param ( $BuildNumber = $env:BUILD_NUMBER ,
[ Parameter ( Mandatory = $true ) ]
[ string ] $testLocation ,
[ Parameter ( Mandatory = $true ) ]
2018-01-05 10:17:48 +03:00
[ string ] $DistroIdentifier ,
2017-12-19 09:51:24 +03:00
[ Parameter ( Mandatory = $true ) ]
[ string ] $testCycle ,
[ string ] $ARMImageName ,
[ string ] $OsVHD ,
[ string ] $OverrideVMSize ,
2017-12-26 12:51:23 +03:00
2017-12-19 09:51:24 +03:00
[ switch ] $EnableAcceleratedNetworking ,
2018-01-05 10:17:48 +03:00
[ string ] $customKernel ,
[ string ] $customLIS ,
2017-12-19 09:51:24 +03:00
[ string ] $customLISBranch ,
[ switch ] $ForceDeleteResources ,
2018-04-02 05:41:08 +03:00
[ switch ] $keepReproInact ,
2017-12-26 13:34:00 +03:00
[ string ] $customSecretsFilePath = " " ,
[ string ] $ArchiveLogDirectory = " " ,
[ string ] $ResultDBTable = " " ,
[ string ] $ResultDBTestTag = " " ,
[ string ] $RunSelectedTests = " " ,
2018-01-04 06:22:14 +03:00
[ string ] $StorageAccount = " " ,
2018-03-07 22:28:56 +03:00
[ string ] $customParameters = " " ,
2018-03-02 23:10:01 +03:00
[ int ] $coureCountExceededTimeout ,
2018-03-12 03:58:56 +03:00
[ int ] $testIterations = 1 ,
[ int ] $maxDirLength = 32 ,
2018-03-21 06:49:49 +03:00
[ string ] $LinuxUsername = " " ,
[ string ] $LinuxPassword = " " ,
2018-02-16 11:54:10 +03:00
[ string ] $tipSessionId = " " ,
[ string ] $tipCluster = " " ,
[ switch ] $UseManagedDisks ,
2018-01-04 06:22:14 +03:00
[ switch ] $ExitWithZero
2017-12-19 09:51:24 +03:00
)
#---------------------------------------------------------[Initializations]--------------------------------------------------------
2018-01-04 21:10:48 +03:00
2017-12-19 09:51:24 +03:00
Write-Host " ----------- $PWD --------- "
2018-04-12 21:16:48 +03:00
$maxDirLength = 32
2018-04-20 04:27:52 +03:00
$shortRandomNumber = Get-Random -Maximum 99999 -Minimum 11111
Set-Variable -Name shortRandomNumber -Value $shortRandomNumber -Scope Global
$shortRandomWord = -join ( ( 65 . .90 ) | Get-Random -Count 4 | % { [ char ] $_ } )
Set-Variable -Name shortRandomWord -Value $shortRandomWord -Scope Global
2018-04-13 06:59:48 +03:00
if ( $pwd . Path . Length -gt $maxDirLength )
2017-12-26 08:09:14 +03:00
{
2017-12-26 08:23:10 +03:00
$originalWorkingDirectory = $pwd
2017-12-27 11:07:25 +03:00
Write-Host " Current working directory length is greather than $maxDirLength . Need to change the working directory. "
$tempWorkspace = $env:TEMP
New-Item -ItemType Directory -Path " $tempWorkspace \az " -Force -ErrorAction SilentlyContinue | Out-Null
2018-01-05 10:17:48 +03:00
New-Item -ItemType Directory -Path " $tempWorkspace \az\ $shortRandomNumber " -Force -ErrorAction SilentlyContinue | Out-Null
$finalWorkingDirectory = " $tempWorkspace \az\ $shortRandomNumber "
2017-12-27 07:41:27 +03:00
$tmpSource = '\\?\' + " $originalWorkingDirectory \* "
2017-12-27 11:07:25 +03:00
Write-Host " Copying current workspace to $finalWorkingDirectory "
Copy-Item -Path $tmpSource -Destination $finalWorkingDirectory -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
2017-12-26 08:09:14 +03:00
Set-Location -Path $finalWorkingDirectory | Out-Null
Write-Host " Wroking directory changed to $finalWorkingDirectory "
}
2018-01-04 21:10:48 +03:00
Remove-Item -Path " .\report\report_ $( ( $TestCycle ) . Trim ( ) ) .xml " -Force -ErrorAction SilentlyContinue
2018-01-07 03:37:02 +03:00
Remove-Item -Path " .\report\testSummary.html " -Force -ErrorAction SilentlyContinue
mkdir -Path . \ report -Force -ErrorAction SilentlyContinue | Out-Null
Set-Content -Value " No tests ran yet. " -Path " .\report\testSummary.html " -Force -ErrorAction SilentlyContinue
2018-01-04 21:10:48 +03:00
2017-12-27 13:50:43 +03:00
. \ Extras \ CheckForNewKernelPackages . ps1
2018-04-17 01:02:54 +03:00
New-Item -Name temp -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null
2017-12-19 09:51:24 +03:00
if ( $customSecretsFilePath ) {
$secretsFile = $customSecretsFilePath
2017-12-26 11:41:40 +03:00
Write-Host " Using user provided secrets file: $( $secretsFile | Split-Path -Leaf ) "
2018-01-30 07:47:03 +03:00
Set-Variable -Name " secretsFile " -Value $customSecretsFilePath -Scope Global
2017-12-19 09:51:24 +03:00
}
if ( $env:Azure_Secrets_File ) {
$secretsFile = $env:Azure_Secrets_File
2018-01-05 10:17:48 +03:00
Write-Host " Using predefined secrets file: $( $secretsFile | Split-Path -Leaf ) in Jenkins Global Environments. "
2017-12-19 09:51:24 +03:00
}
if ( $secretsFile -eq $null ) {
Write-Host " ERROR: Azure Secrets file not found in Jenkins / user not provided -customSecretsFilePath " -ForegroundColor Red -BackgroundColor Black
exit 1
}
if ( Test-Path $secretsFile ) {
Write-Host " AzureSecrets.xml found. "
. \ AddAzureRmAccountFromSecretsFile . ps1 -customSecretsFilePath $secretsFile
$xmlSecrets = [ xml ] ( Get-Content $secretsFile )
2017-12-21 03:41:02 +03:00
Set-Variable -Name xmlSecrets -Value $xmlSecrets -Scope Global
2018-04-17 01:02:54 +03:00
Set-Variable -Name AuthenticatedSession -Value $true -Scope Global
2017-12-19 09:51:24 +03:00
}
2018-01-05 10:17:48 +03:00
else {
2017-12-19 09:51:24 +03:00
Write-Host " AzureSecrets.xml file is not added in Jenkins Global Environments OR it is not bound to 'Azure_Secrets_File' variable. " -ForegroundColor Red -BackgroundColor Black
Write-Host " Aborting. " -ForegroundColor Red -BackgroundColor Black
exit 1
}
if ( $ARMImageName -eq $null -and $OsVHD -eq $null )
{
Write-Host " MISSING PARAMETER: ARMImage and OsVHD parameters are missing. Please give atleast one. "
}
#region Set Jenkins specific variables.
if ( $env:BUILD_NUMBER -gt 0 )
{
Write-Host " Detected Jenkins environment. "
2018-01-31 01:28:01 +03:00
$xmlConfigFileFinal = " $PWD \Azure_Config- $shortRandomNumber .xml "
2017-12-21 12:28:12 +03:00
$xmlConfigFileFinal = $xmlConfigFileFinal . Replace ( '/' , '-' )
2017-12-19 09:51:24 +03:00
}
else
{
Write-Host " Detected local environment. "
2018-01-31 01:28:01 +03:00
$xmlConfigFileFinal = " $PWD \Azure_Config- $testCycle - $DistroIdentifier .xml "
2017-12-19 09:51:24 +03:00
}
#region Select Storage Account Type
$regionName = $testLocation . Replace ( " " , " " ) . Replace ( '"' , " " ) . ToLower ( )
$regionStorageMapping = [ xml ] ( Get-Content . \ XML \ RegionAndStorageAccounts . xml )
2017-12-21 04:42:59 +03:00
if ( $StorageAccount -imatch " ExistingStorage_Standard " )
{
$StorageAccountName = $regionStorageMapping . AllRegions . $regionName . StandardStorage
}
elseif ( $StorageAccount -imatch " ExistingStorage_Premium " )
{
$StorageAccountName = $regionStorageMapping . AllRegions . $regionName . PremiumStorage
}
elseif ( $StorageAccount -imatch " NewStorage_Standard " )
{
$StorageAccountName = " NewStorage_Standard_LRS "
}
elseif ( $StorageAccount -imatch " NewStorage_Premium " )
{
$StorageAccountName = " NewStorage_Premium_LRS "
}
2017-12-26 13:34:00 +03:00
elseif ( $StorageAccount -eq " " )
2017-12-21 04:42:59 +03:00
{
2017-12-21 04:53:42 +03:00
$StorageAccountName = $regionStorageMapping . AllRegions . $regionName . StandardStorage
2017-12-26 13:34:00 +03:00
Write-Host " Auto selecting storage account : $StorageAccountName as per your test region. "
2018-05-16 09:59:45 +03:00
}
elseif ( $StorageAccount -ne " " )
{
$StorageAccountName = $StorageAccount . Trim ( )
Write-Host " Selecting custom storage account : $StorageAccountName as per your test region. "
2017-12-21 04:42:59 +03:00
}
2017-12-19 09:51:24 +03:00
#if ($defaultDestinationStorageAccount -ne $StorageAccountName)
#{
# $OsVHD = "https://$defaultDestinationStorageAccount.blob.core.windows.net/vhds/$OsVHD"
#}
#endregion
#Write-Host "Getting '$StorageAccountName' storage account details..."
#$testLocation = (Get-AzureRmLocation | Where { $_.Location -eq $((Get-AzureRmResource | Where { $_.Name -eq "$StorageAccountName"}).Location)}).DisplayName
#region Prepare workspace for automation.
Set-Content -Value " <pre> " -Path . \ FinalReport . txt -Force
Add-Content -Value " Build process aborted manually. Please check attached logs for more details... " -Path . \ FinalReport . txt -Force
Add-Content -Value " </pre> " -Path . \ FinalReport . txt -Force
mkdir . \ report -Force -ErrorAction SilentlyContinue | Out-Null
2018-01-05 10:17:48 +03:00
Set-Content -Value " " -Path . \ report \ testSummary . html -Force
Set-Content -Value " " -Path . \ report \ lastLogDirectory . txt -Force
2017-12-19 09:51:24 +03:00
#Copy-Item J:\Jenkins\userContent\azure-linux-automation\* -Destination . -Recurse -Force -ErrorAction SilentlyContinue
#Copy-Item J:\Jenkins\userContent\CI\* -Destination . -Recurse -Force -ErrorAction SilentlyContinue
#endregion
#region PREPARE XML FILE
Write-Host " Injecting Azure Configuration data in $xmlConfigFileFinal file.. "
2018-03-07 22:28:56 +03:00
#region Add custom parameters to XML
if ( $customParameters )
{
$customParameters = $customParameters . Replace ( " ^ " , " `n " )
$xmlFileString = Get-Content . \ Azure_ICA_all . xml
foreach ( $replaceString in $customParameters . Split ( " `n " ) )
{
$actualContent = $replaceString . Split ( " = " ) [ 0 ]
$replacement = $replaceString . Split ( " = " ) [ 1 ]
$xmlFileString = $xmlFileString . Replace ( $actualContent , $replacement )
Write-Host " Replaced $actualContent --> $replacement in XML file. "
}
[ xml ] $xmlFileData = [ xml ] ( $xmlFileString )
}
else
{
[ xml ] $xmlFileData = [ xml ] ( Get-Content . \ Azure_ICA_all . xml )
}
#endregion
2017-12-19 09:51:24 +03:00
$xmlFileData . config . Azure . General . SubscriptionID = $xmlSecrets . secrets . SubscriptionID . Trim ( )
$xmlFileData . config . Azure . General . SubscriptionName = $xmlSecrets . secrets . SubscriptionName . Trim ( )
$xmlFileData . config . Azure . General . StorageAccount = $StorageAccountName
$xmlFileData . config . Azure . General . ARMStorageAccount = $StorageAccountName
2018-03-21 06:49:49 +03:00
if ( $LinuxUsername )
{
$xmlFileData . config . Azure . Deployment . Data . UserName = $LinuxUsername . Trim ( )
}
else
{
$xmlFileData . config . Azure . Deployment . Data . UserName = $xmlSecrets . secrets . linuxTestUsername . Trim ( )
}
if ( $LinuxPassword )
{
$xmlFileData . config . Azure . Deployment . Data . Password = '"' + ( $LinuxPassword . Trim ( ) ) + '"'
}
else
{
$xmlFileData . config . Azure . Deployment . Data . Password = '"' + ( $xmlSecrets . secrets . linuxTestPassword . Trim ( ) ) + '"'
}
2017-12-19 09:51:24 +03:00
$xmlFileData . config . Azure . Deployment . Data . Distro [ 0 ] . Name = ( $DistroIdentifier ) . Trim ( )
$xmlFileData . config . Azure . General . AffinityGroup = " "
2018-01-05 10:17:48 +03:00
$newNode = $xmlFileData . CreateElement ( " Location " )
2017-12-19 09:51:24 +03:00
$xmlFileData . config . Azure . General . AppendChild ( $newNode ) | Out-Null
$xmlFileData . config . Azure . General . Location = '"' + " $testLocation " + '"'
if ( $OsVHD )
{
2018-01-05 10:17:48 +03:00
Write-Host " Injecting Os VHD Information in $xmlConfigFileFinal ... "
2017-12-19 09:51:24 +03:00
$xmlFileData . config . Azure . Deployment . Data . Distro [ 0 ] . OsVHD = ( $OsVHD ) . Trim ( )
}
else
{
2018-01-05 10:17:48 +03:00
Write-Host " Injecting ARM Image Information in $xmlConfigFileFinal ... "
2017-12-19 09:51:24 +03:00
$armPub = ( $ARMImageName ) . Split ( " " ) [ 0 ]
$armOffer = ( $ARMImageName ) . Split ( " " ) [ 1 ]
$armSKU = ( $ARMImageName ) . Split ( " " ) [ 2 ]
$armVersion = ( $ARMImageName ) . Split ( " " ) [ 3 ]
$xmlFileData . config . Azure . Deployment . Data . Distro [ 0 ] . ARMImage . Publisher = $armPub
$xmlFileData . config . Azure . Deployment . Data . Distro [ 0 ] . ARMImage . Offer = $armOffer
$xmlFileData . config . Azure . Deployment . Data . Distro [ 0 ] . ARMImage . Sku = $armSKU
$xmlFileData . config . Azure . Deployment . Data . Distro [ 0 ] . ARMImage . Version = $armVersion
}
#endregion
#region Inject DB data to XML
$xmlFileData . config . Azure . database . server = ( $xmlSecrets . secrets . DatabaseServer ) . Trim ( )
$xmlFileData . config . Azure . database . user = ( $xmlSecrets . secrets . DatabaseUser ) . Trim ( )
$xmlFileData . config . Azure . database . password = ( $xmlSecrets . secrets . DatabasePassword ) . Trim ( )
$xmlFileData . config . Azure . database . dbname = ( $xmlSecrets . secrets . DatabaseName ) . Trim ( )
if ( $ResultDBTable )
{
$xmlFileData . config . Azure . database . dbtable = ( $ResultDBTable ) . Trim ( )
}
if ( $ResultDBTestTag )
{
$xmlFileData . config . Azure . database . testTag = ( $ResultDBTestTag ) . Trim ( )
}
else
{
#Write-Host "No Test Tag provided. If test needs DB support please fill testTag."
}
2018-03-07 22:28:56 +03:00
2017-12-19 09:51:24 +03:00
$xmlFileData . Save ( " $xmlConfigFileFinal " )
Write-Host " $xmlConfigFileFinal prepared successfully. "
$currentDir = $PWD
Write-Host " CURRENT WORKING DIRECTORY - $currentDir "
#region Generate trigger command
Remove-Item -Path " .\report\report_ $( ( $TestCycle ) . Trim ( ) ) .xml " -Force -ErrorAction SilentlyContinue
2017-12-19 10:19:33 +03:00
mkdir -Path . \ tools -ErrorAction SilentlyContinue | Out-Null
2018-02-23 01:47:46 +03:00
Import-Module BitsTransfer
2017-12-19 10:19:33 +03:00
if ( ! ( Test-Path -Path . \ tools \ 7za . exe ) )
{
Write-Host " Downloading 7za.exe "
2018-02-23 01:47:46 +03:00
$out = Start-BitsTransfer -Source " https://github.com/iamshital/azure-linux-automation-support-files/raw/master/tools/7za.exe " | Out-Null
2017-12-19 10:19:33 +03:00
}
if ( ! ( Test-Path -Path . \ tools \ dos2unix . exe ) )
{
Write-Host " Downloading dos2unix.exe "
2018-02-23 01:47:46 +03:00
$out = Start-BitsTransfer -Source " https://github.com/iamshital/azure-linux-automation-support-files/raw/master/tools/dos2unix.exe " | Out-Null
2017-12-19 10:19:33 +03:00
}
if ( ! ( Test-Path -Path . \ tools \ plink . exe ) )
{
Write-Host " Downloading plink.exe "
2018-02-23 01:47:46 +03:00
$out = Start-BitsTransfer -Source " https://github.com/iamshital/azure-linux-automation-support-files/raw/master/tools/plink.exe " | Out-Null
2017-12-19 10:19:33 +03:00
}
if ( ! ( Test-Path -Path . \ tools \ pscp . exe ) )
{
Write-Host " Downloading pscp.exe "
2018-02-23 01:47:46 +03:00
$out = Start-BitsTransfer -Source " https://github.com/iamshital/azure-linux-automation-support-files/raw/master/tools/pscp.exe " | Out-Null
2017-12-19 10:19:33 +03:00
}
2017-12-26 11:41:40 +03:00
Move-Item -Path " *.exe " -Destination . \ tools -ErrorAction SilentlyContinue -Force
2017-12-19 10:19:33 +03:00
2017-12-19 09:51:24 +03:00
$cmd = " .\AzureAutomationManager.ps1 -runtests -Distro " + ( $DistroIdentifier ) . Trim ( ) + " -cycleName " + ( $TestCycle ) . Trim ( )
$cmd + = " -xmlConfigFile $xmlConfigFileFinal "
if ( $OverrideVMSize )
{
$cmd + = " -OverrideVMSize $OverrideVMSize "
}
if ( $EconomyMode -eq " True " )
{
$cmd + = " -EconomyMode -keepReproInact "
}
2017-12-21 07:53:48 +03:00
if ( $EnableAcceleratedNetworking )
2017-12-19 09:51:24 +03:00
{
2017-12-21 07:53:48 +03:00
$cmd + = " -EnableAcceleratedNetworking "
2017-12-19 09:51:24 +03:00
}
2017-12-21 12:15:47 +03:00
if ( $ForceDeleteResources )
{
$cmd + = " -ForceDeleteResources "
}
2017-12-19 09:51:24 +03:00
if ( $keepReproInact )
{
$cmd + = " -keepReproInact "
}
if ( $customKernel )
{
2017-12-26 12:51:23 +03:00
$cmd + = " -customKernel ' $customKernel ' "
2017-12-19 09:51:24 +03:00
}
if ( $customLIS )
{
$cmd + = " -customLIS $customLIS "
}
2017-12-21 04:42:59 +03:00
if ( $RunSelectedTests )
{
$cmd + = " -RunSelectedTests ' $RunSelectedTests ' "
}
2018-03-02 23:10:01 +03:00
if ( $coureCountExceededTimeout )
{
$cmd + = " -coureCountExceededTimeout $coureCountExceededTimeout "
}
2018-03-27 08:40:05 +03:00
if ( $testIterations -gt 1 )
{
$cmd + = " -testIterations $testIterations "
}
2018-02-16 11:54:10 +03:00
if ( $tipSessionId )
{
$cmd + = " -tipSessionId $tipSessionId "
}
if ( $tipCluster )
{
$cmd + = " -tipCluster $tipCluster "
}
if ( $UseManagedDisks )
{
$cmd + = " -UseManagedDisks "
}
2017-12-21 04:42:59 +03:00
$cmd + = " -ImageType Standard "
2017-12-19 09:51:24 +03:00
$cmd + = " -UseAzureResourceManager "
Write-Host " Invoking Final Command... "
Write-Host $cmd
Invoke-Expression -Command $cmd
2017-12-27 03:41:08 +03:00
2017-12-19 09:51:24 +03:00
$LogDir = Get-Content . \ report \ lastLogDirectory . txt -ErrorAction SilentlyContinue
2018-04-17 08:13:24 +03:00
$ticks = ( Get-Date ) . Ticks
2018-04-17 01:02:54 +03:00
$currentDir = ( Get-Location ) . Path
2018-03-21 02:47:36 +03:00
$out = Remove-Item * . json -Force
$out = Remove-Item * . xml -Force
2018-04-17 08:13:24 +03:00
$zipFile = " $( ( $TestCycle ) . Trim ( ) ) - $ticks -azure-buildlogs.zip "
2018-03-21 02:47:36 +03:00
$out = ZipFiles -zipfilename $zipFile -sourcedir $LogDir
2018-04-17 02:21:08 +03:00
#region Get a downloadble link of logs...
$testLogFolder = " TestCycleLogs "
$testLogStorageAccount = $xmlSecrets . secrets . testLogsStorageAccount
$testLogStorageAccountKey = $xmlSecrets . secrets . testLogsStorageAccountKey
if ( $env:BUILD_NUMBER -gt 0 )
{
$filePrefix = " $env:BUILD_NUMBER "
}
else
{
$filePrefix = " manual "
}
2018-04-17 02:34:50 +03:00
Rename-Item -Path $zipFile -NewName " $filePrefix - $zipFile " | Out-Null
2018-04-17 02:21:08 +03:00
$compressedFile = . \ Extras \ UploadFilesToStorageAccount . ps1 -filePaths " $filePrefix - $zipFile " -destinationStorageAccount $testLogStorageAccount -destinationContainer " logs " -destinationFolder " $testLogFolder " -destinationStorageKey $testLogStorageAccountKey
LogMsg $compressedFile
#endregion
2017-12-26 11:41:40 +03:00
2017-12-27 03:41:08 +03:00
if ( $ArchiveLogDirectory )
{
Write-Host " Archive test results to : $ArchiveLogDirectory "
$now = Get-Date
$hhmmssC = Get-Date -format " HHMMssfff "
$hhmmssP = Get-Date -format " yyyyMMdd "
$destDir = " $testCycle - $hhmmssC "
Mkdir -Force " $ArchiveLogDirectory \ $hhmmssP " -ErrorAction SilentlyContinue | Out-Null
$FinalDestDir = " $ArchiveLogDirectory \ $hhmmssP \ $destDir "
Mkdir -Force $FinalDestDir -ErrorAction SilentlyContinue | Out-Null
if ( Test-Path -Path $FinalDestDir )
{
Write-Host " $FinalDestDir - Available. "
2017-12-27 11:07:25 +03:00
Write-Host " Entering $FinalDestDir "
2017-12-27 03:41:08 +03:00
cd $LogDir
2017-12-27 13:50:43 +03:00
Write-Host " $LogDir ----------------------- "
2017-12-27 03:41:08 +03:00
Write-Host " Copying all items recursively to $FinalDestDir "
Copy-Item -Path . \ * -Recurse -Destination $FinalDestDir -Force
2018-01-05 10:17:48 +03:00
Write-Host " Done. "
2017-12-27 03:41:08 +03:00
cd $currentDir
}
}
2017-12-19 09:51:24 +03:00
$retValue = 1
try
{
if ( Test-Path -Path " .\report\report_ $( ( $TestCycle ) . Trim ( ) ) .xml " )
{
$resultXML = [ xml ] ( Get-Content " .\report\report_ $( ( $TestCycle ) . Trim ( ) ) .xml " -ErrorAction SilentlyContinue )
2018-01-21 04:28:51 +03:00
Copy-Item -Path " .\report\report_ $( ( $TestCycle ) . Trim ( ) ) .xml " -Destination " .\report\report_ $( ( $TestCycle ) . Trim ( ) ) - $shortRandomNumber -junit.xml " -Force -ErrorAction SilentlyContinue
Write-Host " Copied : .\report\report_ $( ( $TestCycle ) . Trim ( ) ) .xml --> .\report\report_ $( ( $TestCycle ) . Trim ( ) ) - $shortRandomNumber -junit.xml "
Write-Host " Analysing results.. "
Write-Host " PASS : $( $resultXML . testsuites . testsuite . tests - $resultXML . testsuites . testsuite . errors - $resultXML . testsuites . testsuite . failures ) "
Write-Host " FAIL : $( $resultXML . testsuites . testsuite . failures ) "
Write-Host " ABORT : $( $resultXML . testsuites . testsuite . errors ) "
2017-12-19 09:51:24 +03:00
if ( ( $resultXML . testsuites . testsuite . failures -eq 0 ) -and ( $resultXML . testsuites . testsuite . errors -eq 0 ) -and ( $resultXML . testsuites . testsuite . tests -gt 0 ) )
{
$retValue = 0
}
else
{
$retValue = 1
}
}
2018-01-05 10:17:48 +03:00
else
2018-01-04 06:22:14 +03:00
{
Write-Host " Summary file: .\report\report_ $( ( $TestCycle ) . Trim ( ) ) .xml does not exist. Exiting with 1. "
2018-01-05 10:17:48 +03:00
$retValue = 1
2018-01-04 06:22:14 +03:00
}
2017-12-19 09:51:24 +03:00
}
catch
{
Write-Host " $( $_ . Exception . GetType ( ) . FullName , " : " , $_ . Exception . Message ) "
exit 1
}
finally
{
2017-12-26 10:23:49 +03:00
if ( $finalWorkingDirectory )
{
Write-Host " Copying all files to original working directory. "
2017-12-27 07:41:27 +03:00
$tmpDest = '\\?\' + $originalWorkingDirectory
2017-12-27 11:07:25 +03:00
Move-Item -Path " $finalWorkingDirectory \* " -Destination $tmpDest -Force -ErrorAction SilentlyContinue | Out-Null
cd . .
Write-Host " Cleaning $finalWorkingDirectory "
Remove-Item -Path $finalWorkingDirectory -Force -Recurse -ErrorAction SilentlyContinue
Write-Host " Setting workspace to original location: $originalWorkingDirectory "
cd $originalWorkingDirectory
2018-01-04 06:22:14 +03:00
}
if ( $ExitWithZero -and ( $retValue -ne 0 ) )
{
Write-Host " Changed exit code from 1 --> 0. (-ExitWithZero mentioned.) "
2018-01-04 21:10:48 +03:00
$retValue = 0
2018-01-04 06:22:14 +03:00
}
2017-12-19 09:51:24 +03:00
Write-Host " Exiting with code : $retValue "
exit $retValue
2018-03-27 08:40:05 +03:00
}