Skip to content

Pester test script cross Azure DevOps git repo in Azure pipeline fails #2277

Answered by Marc013
Marc013 asked this question in Q&A
Discussion options

You must be logged in to vote

The issue is caused by PSScriptAnalyzer, not Pester.

In the Pester test I validate if a pwsh script is compliant with the default rules of PSScriptAnalyzer. I also added an option to provide a path to custom PSSA rules. This is where it goes wrong.

To obtain the custom rules I run cmdlet Get-ScriptAnalyzerRule

$rules += Get-ScriptAnalyzerRule -CustomRulePath $CustomRulePath -RecurseCustomRulePath

When a path is specified that does not contain custom rules error Exception of type 'System.Exception' was thrown. is thrown.

I've fixed the issue by first validating if custom rules are present at the provided path. If not, the path is ignored.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@fflaten
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Marc013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants