Skip to content

Commit

Permalink
Merge pull request #9466 from Azure/caps-json-fix
Browse files Browse the repository at this point in the history
Fix Caps JSON issue in Pipeline packaging
  • Loading branch information
v-amolpatil authored Nov 28, 2023
2 parents e6d9703 + aaff729 commit dc8dc5e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .script/package-automation/package-generator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ try {
$zipFileExist = $item -match ([regex]::Escape(".zip"))
$pythonFileExist = $item -match ([regex]::Escape(".py"))
$jsonFile = $item -match ([regex]::Escape(".json"))
$capsJsonFile = $item -match ([regex]::Escape(".JSON"))

if ($hostFileExist -or $proxiesFileExist -or $azureDeployFileExist -or $functionFileExist -or $textFileExist -or $zipFileExist -or $pythonFileExist)
{ }
else {
if ($jsonFile -or $capsJsonFile) {
if ($jsonFile) {
$newDataConnectorFilesWithoutExcludedFiles += $item
}
}
Expand Down
21 changes: 19 additions & 2 deletions Tools/Create-Azure-Sentinel-Solution/pipeline/createSolutionV4.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ try
foreach ($file in $filesList)
{
Write-Host "Current file is $file"
$fileExtension = $file -split '\.' | Select-Object -Last 1

if ($objectProperties.Name.ToLower() -eq "parsers") {
$finalPath = "" + $pipelineBasePath + "Solutions/" + $pipelineSolutionName + "/Parsers/" + $file.Replace("Parsers/", "")
Expand Down Expand Up @@ -140,12 +141,28 @@ try

try {
Write-Host "Downloading $finalPath"
$rawData = (New-Object System.Net.WebClient).DownloadString($finalPath)
$isFilePathPresent = Test-Path -Path "$finalPath"
Write-Host "Is $finalPath file path present $isFilePathPresent"
if ($isFilePathPresent) {
$rawData = (New-Object System.Net.WebClient).DownloadString($finalPath)
}
else {
if ($fileExtension -eq "json" -or $fileExtension -eq "JSON") {
Write-Host "FinalPath $finalPath not found!"
if ($fileExtension -eq "json") {
$finalPath = $finalPath.Replace(".json", ".JSON")
} else {
$finalPath = $finalPath.Replace(".JSON", ".json")
}
Write-Host "Updated FinalPath is $finalPath"
$rawData = (New-Object System.Net.WebClient).DownloadString($finalPath)
}
}
}
catch {
Write-Host "Failed to download $finalPath -- Please ensure that it exists in $([System.Uri]::EscapeUriString($basePath))" -ForegroundColor Red
Send-AppInsightsExceptionTelemetry -InstrumentationKey $instrumentationKey -Exception $_.Exception -CustomProperties @{ 'RunId'="$runId"; 'PullRequestNumber'= "$pullRequestNumber"; 'ErrorDetails'="CreateSolutionV4 : Error occured in catch block: $_"; 'EventName'="CreateSolutionV4" }
break;
exit 1;
}

try {
Expand Down

0 comments on commit dc8dc5e

Please sign in to comment.