This project is a sample module to experiment with a PowerShell Build Pipeline and its various steps. It includes minumum component of a real module, but with minimum amount of code.
The goal is to have a sandbox to experiment with a PowerShell Module pipeline, develop re-usable steps in a maintainable, re-usable fashion.
Eventually, the aim is to extract this structure and the key re-usable files into a Plaster template.
Build Tasks
Tests
Invoke-pester -ExcludeTag HelpQuality
Build
.init.ps1
should be fairly static and do just enough to bootstrap any project, the rest of the environment initialization should be handled by dedicated modules such as PSDepend for installing required module/lib.
.build.ps1
is where most of the Build customization is done for the project. This is where the default task .
is composed by importing required tasks exposed by different modules (i.e. BuildHelpers). The logic should be minimum: ordering/selecting tasks, so that this high level abstraction only gives the overview and the overridden parameter values.
Param (
[String]
#Override the Parameter of every tasks using $BuildOutput (i.e. [QualityTests](.build/Pester/QualityTests.pester.build.ps1))
$BuildOutput = "$PSScriptRoot\BuildOutput"
)
#Import custom tasks
Get-ChildItem -Path "$PSScriptRoot/.build/" -Recurse -Include *.ps1 -Verbose |
Foreach-Object {
"Importing file $($_.BaseName)"
. $_.FullName
}
#Compose pre-existing tasks in custom workflow
task . ResolveDependencies,
SetBuildVariable,
UnitTests,
DoSomethingBeforeFailing,
FailBuildIfFailedUnitTest,
IntegrationTests,
QualityTestsStopOnFail
Eventually, the composition should be DSL powered similar to what Brandon Padgett suggested:
#Rough idea, needs to play with...
# The idea is that the With could automatically resolve Module,
# with discoverable tasks and then auto-load the available parameters/DSL for that task.
BuildWorkflow SampleBuild {
Task Init {
With BuildHelpers {
Task Clean
}
}
Task Build {
With PSDeploy {
Task Deploy
Tag Build
StepVersion Minor
DependingOn Init
}
}
Task Test {
Path "$ProjectRoot\Tests"
DependingOn Build
}
Task Publish {
With PSDeploy {
Tag Publish
DependingOn Test
}
}
}