Full CI/CD PowerShell Module for with Plaster
Old Friends
Long time ago (link) I’ve created a little helper function to ease creation of PowerShell modules. Since then I’ve learnt a lot of new stuff, but most importantly I’ve met Plaster. I’ve decided to revisit the idea of scaffolding a PowerShell module with Plaster.
New Friends
I’m using this template for some time now, but never found time to publish it. If You’ve been to our Polish PowerShell User Group #10 Meetup, You could get a sneak peak of it being used in our CI/CD chain both for open source (AppVeyor and GitHub) and closed source (TeamCity in Objectivity). We (with Tomek Dabrowski) had the privilege to show that during PSConfEU 2018 (YouTube and slides ) as well.
The Benefit
What is the benefit of using Plaster? Simplicity and repeatability when creating new modules. It can also be used to create functions and tests files based on another template (that is yet to be discovered by me :)) ) If you’d like to know more, these are the best sources to start from:
- Kevin Marquette - Powershell: Adventures in Plaster and Powershell: GetPlastered, a Plaster template to create a Plaster template
- Mike F Robbins - Using Plaster to create a PowerShell Script Module template and PowerShell Script Module Design: Plaster Template for Creating Modules
- David Christian - Working with Plaster (YouTube) and Working with Plaster (blog)
Our PPoShTemplate creates basic folder structure, script style rules for PSScriptAnalyzer and adds build scripts to support both local runs and with CI/CD (works well with TeamCity and AppVeyor). The bonus is that if you clone your repo’s wiki it will regenerate it during local build run (details in our video from PSConfEU).
How to Use it
This is VERY simple - just download/clone this repo PlasterModuleTemplate and Invoke-Plaster
$PlasterTemplatePath = 'Path to PPoshModule template folder' #Path to where you've downloaded this module | |
$DestinationPath = 'C:\AdminTools\ModuleTest1' #Path to your git repository folder | |
Invoke-Plaster -TemplatePath $PlasterTemplatePath -DestinationPath $DestinationPath |
This will trigger Plaster. After you answer some questions your new module will be created:
____ _ _ | |
| _ \| | __ _ ___| |_ ___ _ __ | |
| |_) | |/ _` / __| __/ _ \ '__| | |
| __/| | (_| \__ \ || __/ | | |
|_| |_|\__,_|___/\__\___|_| | |
v1.1.3 | |
================================================== | |
Author (Mateusz Czerniawski): | |
Name of your module: TestModule1 | |
Version Number (0.0.1): | |
Brief Description of your module: This is for testing purpose | |
Please select folders to include | |
[P] Public | |
[P] Private | |
[C] Configuration | |
[?] Help | |
(default choices are P,P,C) | |
Choice[0]: | |
Add Git Support | |
[Y] Yes [N] No [?] Help (default is "Y"): | |
Select a license for your module | |
[A] Apache [M] MIT [N] None [?] Help (default is "M"): M | |
Include Pester Tests? | |
[Y] Yes [N] No [?] Help (default is "Y"): | |
Include PPoShBuild Support? | |
[Y] Yes [N] No [?] Help (default is "Y"): | |
Include PPoShTools requirement file? | |
[Y] Yes [N] No [?] Help (default is "Y"): | |
Add VSCode support? | |
[Y] Yes [N] No [?] Help (default is "Y"): | |
Add Docs folder? | |
[Y] Yes [N] No [?] Help (default is "Y"): | |
Destination path: C:\AdminTools\ModuleTest1\ | |
Setting up your project | |
Create TestModule1\TestModule1.psd1 | |
Create TestModule1\TestModule1.psm1 | |
Creating you folders for module: | |
Create TestModule1\Public\ | |
Create TestModule1\Private\ | |
Create TestModule1\Configuration\ | |
Setting up support for GIT | |
Create .gitignore | |
Create README.md | |
Create LICENSE.txt | |
Setting up support for Pester | |
Verify The required module Pester (minimum version: 3.4.0) is already installed. | |
Create Tests\ | |
Create Tests\TestModule1.tests.ps1 | |
Setting up support for PPoShBuild | |
Create build\ | |
Create build\build.ps1 | |
Create build\build.depend.psd1 | |
Create build\appveyor.yml | |
Create build\PPoShScriptingStyle.psd1 | |
Create build\psake.ps1 | |
Setting up Requirements.psd1 file for PPoShTools | |
Create requirements.psd1 | |
Setting up support for VSCode | |
Create .vscode\settings.json | |
Create .vscode\launch.json | |
Setting up Docs folder | |
Create docs\Quick-Start-Installation-and-Example.md | |
Create SomeTestModule1\Docs\New-Module-Create.md |
What’s next
Currently we’re preparing to add Azure DevOps Services (a.k.a VSTS) into the mix, so soon additional files in build directory will be added to support that.
Leave a comment