forked from StartAutomating/PSDevOps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Steps for PSScriptAnalyzer and Installing PSDevOps.
Adding PowerShell Static Analysis Stage
- Loading branch information
1 parent
8a5dd57
commit 14c113f
Showing
4 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@{ | ||
stage = 'PowerShellStaticAnalysis' | ||
displayName = 'Static Analysis' | ||
condition= "and(succeeded())" | ||
jobs = @(@{ | ||
job = 'PSScriptAnalyzer' | ||
displayName = 'PSScriptAnalyzer' | ||
pool=@{ | ||
vmImage= 'vs2017-win2016' | ||
} | ||
steps = @('InstallPSDevOps', 'InstallPSScriptAnalyzer','RunPSScriptAnalyzer') | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Install-Module -Name PSDevOps -Repository PSGallery -Force -Scope CurrentUser | ||
Import-Module PSDevOps -Force -PassThru |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Force -Scope CurrentUser | ||
Import-Module PSScriptAnalyzer -Force -PassThru |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Import-Module PSScriptAnalyzer, PSDevOps | ||
$invokeScriptAnalyzerSplat = @{Path='.\'} | ||
if ($ENV:PSScriptAnalyzer_Recurse) { | ||
$invokeScriptAnalyzerSplat.Recurse = $true | ||
} | ||
$result = Invoke-ScriptAnalyzer @invokeScriptAnalyzerSplat | ||
|
||
foreach ($r in $result) { | ||
if ('information', 'warning' -contains $r.Severity) { | ||
Write-ADOWarning -Message $r.Message -SourcePath $r.ScriptPath -LineNumber $r.LineNumber -ColumnNumber $r.ColumnNumber | ||
} | ||
elseif ($r.Severity -eq 'Error') { | ||
Write-ADOError -Message $r.Message -SourcePath $r.ScriptPath -LineNumber $r.LineNumber -ColumnNumber $r.ColumnNumber | ||
} | ||
} |