diff --git a/pipelines/azure-pipelines.yml b/pipelines/azure-pipelines.yml index e370b59a..74b1f084 100644 --- a/pipelines/azure-pipelines.yml +++ b/pipelines/azure-pipelines.yml @@ -93,4 +93,21 @@ extends: inputs: testResultsFormat: "NUnit" testResultsFiles: "**/Test*.xml" - failTaskOnFailedTests: true \ No newline at end of file + failTaskOnFailedTests: true + + - task: PowerShell@2 + displayName: "Run PSScriptAnalyzer for DSC modules" + inputs: + pwsh: true + targetType: "inline" + script: | + Invoke-ScriptAnalyzer -Path * -Recurse -Outvariable issues + $errors = $issues.Where({$_.Severity -eq 'Error'}) + $warnings = $issues.Where({$_.Severity -eq 'Warning'}) + if ($errors) + { + Write-Error "There were $($errors.Count) errors." -ErrorAction Stop + } + Write-Output "There were $($warnings.Count) warnings total." + workingDirectory: $(Build.SourcesDirectory)\resources\ + ignoreLASTEXITCODE: true \ No newline at end of file