Troubleshooting deployment failure after upgrade to 3.0

Hi,

After upgrading to v3.0 (v3.0.6 specifically) we’re getting a deployment failure. This deployment was working fine in v2.6 and there didn’t appear to be any issues upgrading. How do we get to see the contents of the ‘pre deploy’ powershell script (Bootstrap.Octopus.Action.CustomScripts.PreDeploy.ps1) as it seems to be deleted after the unsuccessful deployment attempt?

Deploying package ‘C:\Octopus\Files\XXX.Services.0.0.0.99.nupkg-f5530d0a-1cc5-4d9e-9589-2c6ce23708f2’ to machine 'https://machine:10933/'
08:56:08Info
Deploying package: C:\Octopus\Files\XXX.Services.0.0.0.99.nupkg-f5530d0a-1cc5-4d9e-9589-2c6ce23708f2
08:56:08Info
Using variables from: C:\Octopus\Work\20150728205604-54\Variables.json
08:56:16Error
At C:\Octopus\Applications\Continuous Integration\XXX.Services
08:56:16Error
\0.0.0.99\Bootstrap.Octopus.Action.CustomScripts.PreDeploy.ps1:1193 char:31
08:56:16Error

  • $ErrorActionPreference = 'Stop’
    08:56:16Error
  •                           ~
    

08:56:16Error
The string is missing the terminator: '.
08:56:16Error
At C:\Octopus\Applications\Continuous Integration\XXX.Services
08:56:16Error
\0.0.0.99\Bootstrap.Octopus.Action.CustomScripts.PreDeploy.ps1:301 char:1
08:56:16Error

  • {
    08:56:16Error
  • ~
    08:56:16Error
    Missing closing ‘}’ in statement block.
    08:56:16Error
    At C:\Octopus\Applications\Continuous Integration\XXX.Services
    08:56:16Error
    \0.0.0.99\Bootstrap.Octopus.Action.CustomScripts.PreDeploy.ps1:300 char:76
    08:56:16Error
  • New-Module -Name Library_WindowsServiceBus_635737569710889976 -ScriptBlock
    08:56:16Error
    {func …
    08:56:16Error
  •                                                                        ~
    

08:56:16Error
Missing closing ‘}’ in statement block.
08:56:16Error
+ CategoryInfo : ParserError: (:slight_smile: [], ParseException
08:56:16Error
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

Hi Murray,

Thanks for getting in touch.

So I know I’m on the right page, you do have a custom powershell script for one of your steps ?
It should be written directly from your project config to the filesystem, are you able to paste the script here ?

Regards

Damian

Hi Damian,

Yes, I do but it calls library modules which is why I’d like to see what Octopus has put together to see where the mismatched ’ is:

UnInstallService “XXX.Services” (join-path $OctopusParameters[‘Octopus.Action[Deploy XXX Service].Package.CustomInstallationDirectory’] “XXX.Services.exe”)

Hi Murray,

Thanks for the clarification, I understand now.

It’s tricky, there isn’t a great way to do this because as you’ve observed we clean up these files as soon as they’ve been executed.

I have two horrible hacky thoughts as quick wins. First is build a little app with a filesystemwatcher in it to grab a copy of the file once it’s created. The second is to make a fork of Calamari which doesn’t delete the file. I don’t suppose either of those things are something you have an appetite to do ?

We could look at doing a debug calamari option / switch if this was going to be a common occurrence.

The other thing is you could set up an offline target and at lease see what the script modules were getting passed through as.

How many script modules do you have ?

Damian

Thanks Damian for the advice. Thought there might have been a switch or somesuch (and I’d say that’s a worthwhile addition) but I wrote a console app to grab the file. It turns out, for whatever reason, the upgrade to 3.0 must have changed some characters in the library module in the import or the way the powershell script is created has been changed. Via the Octopus UI the function in question looks like:

function ServiceBusEnableAccess($nameSpace, $users)
{
Import-Module ServiceBus
Set-SBNamespace –Name $nameSpace -ManageUsers $users
}

Looking carefully the - before Name and - before ManageUsers is a different character. Not sure how this happened when we authored it?!. This worked fine in v2.6 (and powershell previously).

but in the deploy script it is corrupted (note the -Name has now become –Name - corrupted is a strong word, more like encoding has changed to ASCII or something and powershell doesn’t like it):

New-Module -Name Library_WindowsServiceBus_635738436982077347 -ScriptBlock {function ServiceBusEnableAccess($nameSpace, $users)
{
Import-Module ServiceBus
Set-SBNamespace –Name $nameSpace -ManageUsers $users
}

(truncated)

Thanks for your help.

Thanks for the debug info Murray (and yes a Calamari switch would have been handy for this)

I’ve created a GitHub issue here https://github.com/OctopusDeploy/Issues/issues/1809

It looks like a bug to me, we had some juggling in 2.x to get the right combination of encodings for scripts and I think we might not be doing enough in 3.0.

Now you’ve identified the issue have you been able to edit the script and get it working or are you still in a broken state ?

Regards

Damian

All sorted now thanks Damian. I overwrote the characters in the editor and deployments are working fine now.