Custom Script Modules

Script modules are the function library your inline scripts wish they had.

A script module is a PowerShell module managed by Jaws Deploy that any script step in any project can Import-Module and call. It's the right home for helper functions that several scripts share - authentication wrappers, database helpers, notification utilities.

// Step templates

When the consumer fills out a form

Templates are actions with UI. Pick from the step picker, fill the inputs, get a step.

// Script modules

When the consumer writes a script

Modules are libraries. The consumer is writing their own script and wants to not rewrite a function.

// Using a module from a script step

Inside any script step in any project

The platform handles distribution and version pinning of the module.

Import-Module JawsCommon

$token  = Get-AzureToken -Scope $Variables['Azure.Scope']
$conn   = Get-SqlConnection -Variable 'Db.Conn'
$result = Invoke-Migration -Connection $conn -ToVersion $env:ReleaseVersion

Send-SlackNotification -Channel "#deploys" -Message "Deployed v$env:ReleaseVersion to $($Octopus.Environment.Name)"

What belongs in a module

Pure functions used in multiple steps. Logging helpers. Notification senders. Authentication wrappers. Database connection helpers. Things you've written more than once in inline scripts and are tired of re-finding the original.