You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looks like “Connect-OctoServer” does not work if calls are done between ps1 file and psm1 module, is that expected?
Using Octopus-CmdLets 0.4.4 and Powershell 5.1
Test.psm1
function Get-EnvironmentViaModule()
{
"getting all environments..."
Get-OctoEnvironment
}
Test.ps1
Import-Module .\Test.psm1
$ApiKey = "API-xxxx"
$Url = "https://octopus.xxx.com"
Connect-OctoServer -Server $Url -ApiKey $ApiKey
"connected..."
Get-EnvironmentViaModule # this fails - but a direct "Get-OctoEnvironment" works
Execution:
> .\Test.ps1
connected...
getting all environments...
Get-OctoEnvironment : Connection not established. Please connect to your Octopus Deploy instance with
Connect-OctoServer
At C:\Users\andrew\Test.psm1:4 char:5
+ Get-OctoEnvironment
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-OctoEnvironment], Exception
+ FullyQualifiedErrorId : System.Exception,Octopus_Cmdlets.GetEnvironment
The text was updated successfully, but these errors were encountered:
This is by design. Albeit a bad design. The variable set by the connect command is scoped to your terminal session and isn't available in modules. I will investigate improving this.
Looks like “Connect-OctoServer” does not work if calls are done between ps1 file and psm1 module, is that expected?
Using Octopus-CmdLets 0.4.4 and Powershell 5.1
Execution:
The text was updated successfully, but these errors were encountered: