Skip to content

Commit 4929ce8

Browse files
authored
Add error handling for CI steps (Azure#22423)
1 parent 2a6fd58 commit 4929ce8

File tree

1 file changed

+71
-7
lines changed

1 file changed

+71
-7
lines changed

tools/ExecuteCIStep.ps1

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,49 @@ If ($StaticAnalysis)
394394
{
395395
$Parameters["TargetModule"] = $TargetModule
396396
}
397-
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisBreakingChange @Parameters
398-
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisDependency @Parameters
399-
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisSignature @Parameters
400-
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisHelp @Parameters
401-
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisUX @Parameters
402-
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisCmdletDiff @Parameters
403-
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisGeneratedSdk @Parameters
397+
$FailedTasks = @()
398+
$ErrorLogPath = "$StaticAnalysisOutputDirectory/error.log"
399+
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisBreakingChange @Parameters 2>$ErrorLogPath
400+
If ($LASTEXITCODE -ne 0)
401+
{
402+
$FailedTasks += "BreakingChange"
403+
}
404+
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisDependency @Parameters 2>>$ErrorLogPath
405+
If ($LASTEXITCODE -ne 0)
406+
{
407+
$FailedTasks += "Dependency"
408+
}
409+
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisSignature @Parameters 2>>$ErrorLogPath
410+
If ($LASTEXITCODE -ne 0)
411+
{
412+
$FailedTasks += "Signature"
413+
}
414+
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisHelp @Parameters 2>>$ErrorLogPath
415+
If ($LASTEXITCODE -ne 0)
416+
{
417+
$FailedTasks += "Help"
418+
}
419+
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisUX @Parameters 2>>$ErrorLogPath
420+
If ($LASTEXITCODE -ne 0)
421+
{
422+
$FailedTasks += "UXMetadata"
423+
}
424+
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisCmdletDiff @Parameters 2>>$ErrorLogPath
425+
If ($LASTEXITCODE -ne 0)
426+
{
427+
$FailedTasks += "CmdletDiff"
428+
}
429+
.("$PSScriptRoot/ExecuteCIStep.ps1") -StaticAnalysisGeneratedSdk @Parameters 2>>$ErrorLogPath
430+
If ($LASTEXITCODE -ne 0)
431+
{
432+
$FailedTasks += "GenertedSdk"
433+
}
434+
If ($FailedTasks.Length -ne 0)
435+
{
436+
Write-Host "There are failed tasks: $FailedTasks"
437+
$ErrorLog = Get-Content -Path $ErrorLogPath | Join-String -Separator "`n"
438+
Write-Error $ErrorLog
439+
}
404440
Return
405441
}
406442

@@ -418,6 +454,10 @@ If ($StaticAnalysisBreakingChange)
418454
{
419455
Write-Host "Running static analysis for breaking change..."
420456
dotnet $RepoArtifacts/StaticAnalysis/StaticAnalysis.Netcore.dll -p $RepoArtifacts/$Configuration -r $StaticAnalysisOutputDirectory --analyzers breaking-change -u -m $BreakingChangeCheckModuleList
457+
If ($LASTEXITCODE -ne 0)
458+
{
459+
Return $LASTEXITCODE
460+
}
421461
}
422462
Return
423463
}
@@ -435,6 +475,10 @@ If ($StaticAnalysisDependency)
435475
{
436476
Write-Host "Running static analysis for dependency..."
437477
dotnet $RepoArtifacts/StaticAnalysis/StaticAnalysis.Netcore.dll -p $RepoArtifacts/$Configuration -r $StaticAnalysisOutputDirectory --analyzers dependency -u -m $DependencyCheckModuleList
478+
If ($LASTEXITCODE -ne 0)
479+
{
480+
Return $LASTEXITCODE
481+
}
438482
.($PSScriptRoot + "/CheckAssemblies.ps1") -BuildConfig $Configuration
439483
}
440484
Return
@@ -454,6 +498,10 @@ If ($StaticAnalysisSignature)
454498
{
455499
Write-Host "Running static analysis for signature..."
456500
dotnet $RepoArtifacts/StaticAnalysis/StaticAnalysis.Netcore.dll -p $RepoArtifacts/$Configuration -r $StaticAnalysisOutputDirectory --analyzers signature -u -m $SignatureCheckModuleList
501+
If ($LASTEXITCODE -ne 0)
502+
{
503+
Return $LASTEXITCODE
504+
}
457505
}
458506
Return
459507
}
@@ -472,6 +520,10 @@ If ($StaticAnalysisHelp)
472520
{
473521
Write-Host "Running static analysis for help..."
474522
dotnet $RepoArtifacts/StaticAnalysis/StaticAnalysis.Netcore.dll -p $RepoArtifacts/$Configuration -r $StaticAnalysisOutputDirectory --analyzers help -u -m $HelpCheckModuleList
523+
If ($LASTEXITCODE -ne 0)
524+
{
525+
Return $LASTEXITCODE
526+
}
475527
}
476528
Return
477529
}
@@ -490,6 +542,10 @@ If ($StaticAnalysisUX)
490542
{
491543
Write-Host "Running static analysis for UX metadata..."
492544
dotnet $RepoArtifacts/StaticAnalysis/StaticAnalysis.Netcore.dll -p $RepoArtifacts/$Configuration -r $StaticAnalysisOutputDirectory --analyzers ux -u -m $UXModuleList
545+
If ($LASTEXITCODE -ne 0)
546+
{
547+
Return $LASTEXITCODE
548+
}
493549
}
494550
Return
495551
}
@@ -508,6 +564,10 @@ If ($StaticAnalysisCmdletDiff)
508564
{
509565
Write-Host "Running static analysis for cmdlet diff..."
510566
dotnet $RepoArtifacts/StaticAnalysis/StaticAnalysis.Netcore.dll -p $RepoArtifacts/$Configuration -r $StaticAnalysisOutputDirectory --analyzers cmdlet-diff -u -m $CmdletDiffModuleList
567+
If ($LASTEXITCODE -ne 0)
568+
{
569+
Return $LASTEXITCODE
570+
}
511571
}
512572
Return
513573
}
@@ -527,6 +587,10 @@ If ($StaticAnalysisGeneratedSdk)
527587
Write-Host "Running static analysis to verify generated sdk..."
528588
$result = .($PSScriptRoot + "/StaticAnalysis/GeneratedSdkAnalyzer/SDKGeneratedCodeVerify.ps1")
529589
Write-Host "Static analysis to verify generated sdk result: $result"
590+
If ($LASTEXITCODE -ne 0)
591+
{
592+
Return $LASTEXITCODE
593+
}
530594
}
531595
Return
532596
}

0 commit comments

Comments
 (0)