From fc1d208e4a30d57baf55f7e4ca4bcfa1699991df Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Sat, 13 Jun 2020 12:59:26 +0100 Subject: [PATCH 1/7] Report full stack trace if ScriptAnalyzer throws an error --- build/pipelines/templates/run-staticAnalysis.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pipelines/templates/run-staticAnalysis.yaml b/build/pipelines/templates/run-staticAnalysis.yaml index feddaa9b..cb5f6354 100644 --- a/build/pipelines/templates/run-staticAnalysis.yaml +++ b/build/pipelines/templates/run-staticAnalysis.yaml @@ -4,12 +4,12 @@ # steps: - - powershell: | - Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Scope CurrentUser -AllowClobber -SkipPublisherCheck -Force -Verbose + - pwsh: | + Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Scope CurrentUser -Verbose displayName: 'Install PSScriptAnalyzer' - - powershell: | - $results = Invoke-ScriptAnalyzer -Path ./ –Recurse + - pwsh: | + $results = try { Invoke-ScriptAnalyzer -Path ./ –Recurse -ErrorAction Stop } catch { Get-Error } $results | ForEach-Object { Write-Host "##vso[task.logissue type=$($_.Severity);sourcepath=$($_.ScriptPath);linenumber=$($_.Line);columnnumber=$($_.Column);]$($_.Message)" } $null = New-Item -Path ..\ -Name ScriptAnalyzer -ItemType Directory -Force From 56aef783ac0abb489cb5752e170f092251deba4f Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Sat, 13 Jun 2020 14:38:04 +0100 Subject: [PATCH 2/7] Update CONTRIBUTING.md --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dff45883..3bb7e8d8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -486,6 +486,7 @@ Thank you to all of our contributors, no matter how big or small the contributio - **[Shannon Deminick (@Shazwazza)](http://github.com/Shazwazza)** - **[Jess Pomfret (@jpomfret)](https://github.com/jpomfret)** - **[Giuseppe Campanelli (@themilanfan)](https://github.com/themilanfan)** +- **[Christoph Bergmeister (@bergmeister)](https://github.com/bergmeister)** ---------- From e7d00a8c5e1a436978851b3a5b92dca3a0af091b Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Sat, 13 Jun 2020 19:11:01 +0100 Subject: [PATCH 3/7] Update run-staticAnalysis.yaml --- build/pipelines/templates/run-staticAnalysis.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pipelines/templates/run-staticAnalysis.yaml b/build/pipelines/templates/run-staticAnalysis.yaml index cb5f6354..85075809 100644 --- a/build/pipelines/templates/run-staticAnalysis.yaml +++ b/build/pipelines/templates/run-staticAnalysis.yaml @@ -9,7 +9,7 @@ steps: displayName: 'Install PSScriptAnalyzer' - pwsh: | - $results = try { Invoke-ScriptAnalyzer -Path ./ –Recurse -ErrorAction Stop } catch { Get-Error } + $results = try { Invoke-ScriptAnalyzer -Path ./ –Recurse -ErrorAction Stop } catch { Get-Error; throw } $results | ForEach-Object { Write-Host "##vso[task.logissue type=$($_.Severity);sourcepath=$($_.ScriptPath);linenumber=$($_.Line);columnnumber=$($_.Column);]$($_.Message)" } $null = New-Item -Path ..\ -Name ScriptAnalyzer -ItemType Directory -Force From 36feb52afe38626372bd4fb128a8c841cc3be0c2 Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Sat, 13 Jun 2020 19:48:42 +0100 Subject: [PATCH 4/7] Update run-staticAnalysis.yaml --- build/pipelines/templates/run-staticAnalysis.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/pipelines/templates/run-staticAnalysis.yaml b/build/pipelines/templates/run-staticAnalysis.yaml index 85075809..35b11b02 100644 --- a/build/pipelines/templates/run-staticAnalysis.yaml +++ b/build/pipelines/templates/run-staticAnalysis.yaml @@ -4,12 +4,12 @@ # steps: - - pwsh: | + - powershell: | Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Scope CurrentUser -Verbose displayName: 'Install PSScriptAnalyzer' - - pwsh: | - $results = try { Invoke-ScriptAnalyzer -Path ./ –Recurse -ErrorAction Stop } catch { Get-Error; throw } + - powershell: | + $results = try { Invoke-ScriptAnalyzer -Path ./ –Recurse -ErrorAction Stop } catch { $StackTrace; throw } $results | ForEach-Object { Write-Host "##vso[task.logissue type=$($_.Severity);sourcepath=$($_.ScriptPath);linenumber=$($_.Line);columnnumber=$($_.Column);]$($_.Message)" } $null = New-Item -Path ..\ -Name ScriptAnalyzer -ItemType Directory -Force From 8e4b83067e4f985abbea46daf0a9de12f7549963 Mon Sep 17 00:00:00 2001 From: Howard Wolosky Date: Sat, 13 Jun 2020 12:06:13 -0700 Subject: [PATCH 5/7] Update build/pipelines/templates/run-staticAnalysis.yaml --- build/pipelines/templates/run-staticAnalysis.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pipelines/templates/run-staticAnalysis.yaml b/build/pipelines/templates/run-staticAnalysis.yaml index 35b11b02..bceb2408 100644 --- a/build/pipelines/templates/run-staticAnalysis.yaml +++ b/build/pipelines/templates/run-staticAnalysis.yaml @@ -5,7 +5,7 @@ steps: - powershell: | - Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Scope CurrentUser -Verbose + Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Scope CurrentUser -AllowClobber -SkipPublisherCheck -Force -Verbose displayName: 'Install PSScriptAnalyzer' - powershell: | From 8b1dd9b81218d15c5c10fab0744385d7cd8bb08c Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Sat, 13 Jun 2020 20:49:27 +0100 Subject: [PATCH 6/7] Remove redundant AllowClobber and SkipPublisherCheck switches for PSSA bootstrap --- build/pipelines/templates/run-staticAnalysis.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pipelines/templates/run-staticAnalysis.yaml b/build/pipelines/templates/run-staticAnalysis.yaml index bceb2408..dd822160 100644 --- a/build/pipelines/templates/run-staticAnalysis.yaml +++ b/build/pipelines/templates/run-staticAnalysis.yaml @@ -5,7 +5,7 @@ steps: - powershell: | - Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Scope CurrentUser -AllowClobber -SkipPublisherCheck -Force -Verbose + Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Scope CurrentUser -Force -Verbose displayName: 'Install PSScriptAnalyzer' - powershell: | From d302f42ab027955c3fc74a44dbe8ee2d329dc6ec Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Mon, 15 Jun 2020 09:57:43 +0100 Subject: [PATCH 7/7] report exception specific stack trace as $StackTrace is the high level one from PowerShell itself --- build/pipelines/templates/run-staticAnalysis.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pipelines/templates/run-staticAnalysis.yaml b/build/pipelines/templates/run-staticAnalysis.yaml index dd822160..86a673fc 100644 --- a/build/pipelines/templates/run-staticAnalysis.yaml +++ b/build/pipelines/templates/run-staticAnalysis.yaml @@ -9,7 +9,7 @@ steps: displayName: 'Install PSScriptAnalyzer' - powershell: | - $results = try { Invoke-ScriptAnalyzer -Path ./ –Recurse -ErrorAction Stop } catch { $StackTrace; throw } + $results = try { Invoke-ScriptAnalyzer -Path ./ –Recurse -ErrorAction Stop } catch { $_.Exception.StackTrace; throw } $results | ForEach-Object { Write-Host "##vso[task.logissue type=$($_.Severity);sourcepath=$($_.ScriptPath);linenumber=$($_.Line);columnnumber=$($_.Column);]$($_.Message)" } $null = New-Item -Path ..\ -Name ScriptAnalyzer -ItemType Directory -Force