From e761ec893267b33e6c9deeeccb3f8b556a6fc427 Mon Sep 17 00:00:00 2001 From: Faith Kangai Date: Tue, 9 Jul 2024 17:23:03 +0300 Subject: [PATCH] make path to appSettings.json absoluteand present --- pipelines/snippets.yml | 4 +--- scripts/categorizeErrors.ps1 | 10 +++++----- scripts/getWorkloadOwner.ps1 | 10 +++++----- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/pipelines/snippets.yml b/pipelines/snippets.yml index 41b50a538..bd70f6ad3 100644 --- a/pipelines/snippets.yml +++ b/pipelines/snippets.yml @@ -189,8 +189,6 @@ stages: workingDirectory: '$(Build.SourcesDirectory)' - pwsh: | - Write-Host "create file appSettings.json in the workingDirectory" - New-Item -Path $(Build.SourcesDirectory) -Name "appSettings.json" -ItemType "file" -Force Write-Host "Creating folder Reports" New-Item -Path $(Build.SourcesDirectory) -Name "Reports" -ItemType "Directory" -Force displayName: Create requisite directory items @@ -202,7 +200,7 @@ stages: ScriptPath: "$(Build.SourcesDirectory)/scripts/categorizeErrors.ps1" ScriptArguments: " -trxFolderPath '$(Build.ArtifactStagingDirectory)/TestResults/' - -txtOutputFolderPath '$(Build.ArtifactStagingDirectory)/Reports/' + -reportOutputPath '$(Build.ArtifactStagingDirectory)/Reports/' -snippetsBaseErrorPath '$(Build.ArtifactStagingDirectory)' " workingDirectory: '$(Build.SourcesDirectory)' diff --git a/scripts/categorizeErrors.ps1 b/scripts/categorizeErrors.ps1 index 28c62fadc..5fe463949 100644 --- a/scripts/categorizeErrors.ps1 +++ b/scripts/categorizeErrors.ps1 @@ -4,7 +4,7 @@ param( [Parameter(Mandatory=$true)] [string]$snippetsBaseErrorPath, [Parameter(Mandatory=$false)] - [string]$txtOutputFolderPath + [string]$reportOutputPath ) Import-Module ImportExcel @@ -15,10 +15,10 @@ if (!(Test-Path $trxFolderPath)) exit } -#if $txtOutputFolderPath is not set, use current directory -if (-not $txtOutputFolderPath) +#if $reportOutputPath is not set, use current directory +if (-not $reportOutputPath) { - $txtOutputFolderPath = $PSScriptRoot + $reportOutputPath = $PSScriptRoot } $outcomeLocal = "Failed" # Only process failed tests @@ -113,7 +113,7 @@ foreach ($trxFilePath in $files){ } -$excelOutputPath = Join-Path $txtOutputFolderPath "report.xlsx" +$excelOutputPath = Join-Path $reportOutputPath "report.xlsx" $methodNotFound | Export-Excel -Path $excelOutputPath -WorksheetName "MethodNotFound" -AutoSize $pathNotFound | Export-Excel -Path $excelOutputPath -WorksheetName "PathNotFound" -AutoSize $invalidStart | Export-Excel -Path $excelOutputPath -WorksheetName "InvalidStart" -AutoSize diff --git a/scripts/getWorkloadOwner.ps1 b/scripts/getWorkloadOwner.ps1 index 98dae6285..289f519c8 100644 --- a/scripts/getWorkloadOwner.ps1 +++ b/scripts/getWorkloadOwner.ps1 @@ -27,13 +27,13 @@ function Get-AppSettings () return $AppSettings } # read app settings from Azure App Config - $baseWorkingDirectory = $env:WorkingDirectory - if (!$baseWorkingDirectory) + $baseSettingsDirectory = $env:WorkingDirectory + if (!$baseSettingsDirectory) { - $baseWorkingDirectory = $env:TEMP - New-Item -Path $baseWorkingDirectory -Name "appSettings.json" + $baseSettingsDirectory = $env:TEMP } - $appSettingsPath = Join-Path $baseWorkingDirectory "appSettings.json" -Resolve + New-Item -Path $baseSettingsDirectory -Name "appSettings.json" -Force + $appSettingsPath = Join-Path $baseSettingsDirectory "appSettings.json" -Resolve write-host "appsettings path: $appSettingsPath" # Support Reading Settings from a Custom Label, otherwise default to Development $settingsLabel = $env:RAPTOR_CONFIGLABEL