Hi,
We have a series of PowerShell functions (cmdlets), wrapped up into a PowerShell module (.psm1 / .psd1). These are stored in our external NuGet package library (feed). We want to call these functions in steps.
The problem is that the “Run a Script” step is design to do just that, as opposed to a PowerShell module.
Available options
- If I set the “Script Source” to
Inline source code
it disables the options to select the feed and package ID. - If I set the “Script Source” to
Script file inside a package
it wants ascript file name
i.e.Get-Something.ps1
Option 1 is how I have done it in VSTS, calling Import-Module -Name {path_to_psm1} -Force
, however I can’t find a way to reference the package. There don’t seem to be any variables available.
I’d call my cmdlet something like this:
Import-Module -Name #{Octopus.Action['PackageId]} -Force
Get-SomeCmdlet -SomeParam1 #{Var1} -AnotherParam #{Var2}
Option 2 - I can’t create a PS1 file that essential does the pseudo example above as this will break the module. Every time the module is imported / loaded, the PS1 would execute. There is a way around it, but it breaks the module standard and would get messy. I could try creating a separate package for “executable” scripts, and add an additional package but that seems overkill.
It seems to me that we need a third option / new step template “Import PowerShell Module and run cmdlets”.
In the absence of such a step template, can anyone suggest a way to achieve this either with the default steps, or writing our own step template?
We only deploy PaaS, so we have no Tentacles.
TIA