Tentacle error handling with Script Modules

(Greg Bielleman) #1

Hi OctopusDeploy gurus

I’ve created a PSM1 that contains some common functions I use within out deploys,
My deploy.ps1 has the $ErrorActionPreference set to stop.
When i run my deploy.ps1 through standard powershell the script stops if an error occurs in any of the modules functions throw an error. fail, but when tentacle.exe is the host this it continues.
The version of tentacle used in this test was 1.2.3.1476

Is there a workaround for this?

0 Likes

(Greg Bielleman) #2

Hmm, I should have read this properly before i clicked submit…ir gibberish… But hopefully you get the idea - which is errors thrown in script modules do not stop the deploy.ps1 when run through Tentacle when the ErrorActionPreference is set to Stop. Is there a way to make it behave the same way as powershell.exee

0 Likes

(Paul Stovell) #3

Hi Greg,

Do you get the same error when running your scripts via the Tentacle command line?

One difference is that in Octopus we don’t tell PowerShell to run the file - we actually load the file into a string and invoke it that way. So perhaps this is why the behavior is different.

Paul

0 Likes

(Greg Bielleman) #4

Hi Paul,

Yes mate, same behaviour with the tentacle command line.

Cheers
Greg

0 Likes

(Paul Stovell) #5

Hi Greg,

Thanks for the update. I’ve added it to this trello item to take a look at:

https://trello.com/card/alternative-powershell-execution-modes/4e907de70880ba000079b75c/265

Paul

0 Likes

(Greg Bielleman) #6

Hi Paul

Just an FYI

The workaround for this is to set the ErrorActionPreference within the
module as well as the script and then all is well

Cheers
Greg

0 Likes

(system) closed #7
0 Likes