Psscriptanalyzer: How do you incorporate PSScriptAnalyzer as part of your dev process?

Created on 21 Mar 2016  路  4Comments  路  Source: PowerShell/PSScriptAnalyzer

My team wants to leverage this utility to ensure consistent coding practices for all of our custom commandlets. I was hoping to have a discussion and get some insight into how other teams and developers use PSScriptAnalyzer as part of their dev process.

Some questions to get this going:

  • What triggers your analysis? Is it manually run by developers as needed? Does it run as part of your postbuild process? Only in certain build configurations? If it does run with each build, does the build fail if Warnings or Errors are generated?
  • Are the results only for the developer running the analysis to review in their console, or do you take the results and do something with them?
  • How have you addressed performance issues / slowdowns caused by analysis of many Powershell scripts at once?

I realize all teams and organizations are different, and one team's process isn't necessarily going to work for everyone, but I am interested in recommendations for what processes you find work well for yourself and your team.

Issue - Discussion Issue - Question

Most helpful comment

All 4 comments

This is a great question, one I am interested in following. As a newcomer to continuous delivery I have adopted PSScriptAnalyzer as part of my post build process. If warnings / errors are encountered it prevents the powershell module from being sent into its final destination (repository).

I add in ScriptAnalyzer into my Pester Tests - that way I know whether they are passing or not - throughout my test cycles and I can see where I have to spend time working on. I'm just about to publish a blog post on this with some sample code that can be run as well and will pop a link back in here as another response

@albvar How is your environment/project set up? Currently, our modules are built into various solutions based on their product type and functionality. I'm currently modifying the build process so that the script analyzer runs post-build, and the results are output to the console for the developer to see. This is just phase one to get something going.

Next up will be to process these results and do something with the output (fail the build, inform the dev, etc). Pester Tests seem like they might be the next logical place to go with this, so I would be really interested in reading @kilasuit's blog post as well.

Was this page helpful?
0 / 5 - 0 ratings