Deployment fails with return code -12

Some of our Deployments fail (since update to Octopus 1.4) with error code -12.
We added some output of “$LASTEXITCODE” to our Deploy.ps1 script and see that the exit code is not -12 but 0.
We also tried to add “Exit 0” at the end of our Deploy.ps1 script, but the following error appears again:

@@@
[…]
2013-03-14 17:58:06 INFO MongoDB: Rename Collection
2013-03-14 17:58:06 INFO Command: C:\Software\mongodb\bin\mongo.exe localhost/TA-STA --quiet --eval "db[‘FB_new’].renameCollection(‘FB’,true)"
2013-03-14 17:58:09 INFO [object bson_object]
2013-03-14 17:58:09 INFO ----------------------------------
2013-03-14 17:58:09 INFO Allowed ExitCodes : 0
2013-03-14 17:58:09 INFO ----------------------------------
2013-03-14 17:58:09 INFO LASTEXITCODE : 0
2013-03-14 17:58:09 INFO ----------------------------------
2013-03-14 17:58:09 INFO ================================================================================
2013-03-14 17:58:10 INFO Deployment End: 3/14/2013 6:58:09 PM
2013-03-14 17:58:15 DEBUG Script ‘C:\Octopus\Applications\TA-STA\KnowledgeBase.Mongo\1.3.0.7\Deploy.ps1’ completed with return code -12.
2013-03-14 17:58:15 ERROR Octopus.Tentacle.Deployment.Integration.PowerShell.ScriptFailureException: PowerShell script ‘C:\Octopus\Applications\TA-STA\KnowledgeBase.Mongo\1.3.0.7\Deploy.ps1’ returned non-zero exit code: -12. Deployment terminated.
[…]
@@@

Do we have to change anything in our scripts or is it because of the changes in Octopus handling the Powershell scripts in the last version?

Best regards,
Thomas

We are also having this problem.

We previously had a similar problem that some expected error code were being set, but we are not calling $global:LASTEXITCODE = $null to make sure they are not set before the scripts return, but we are now getting the “completed with return code -12.” error.

Same problem here.

I managed to resolve the problem in the short term by fixing the call that was causing the original error code (a call to schtasks to create some scheduled tasks) so this isn’t actually causing us a problem right now. But I imagine the root issue, that having the last exit code as zero is somehow not being recognized by the way Octopus is handling powershell scripts any more still remains.

Wish I had a failing row I could remove. If I look at the LASTEXITCODE last thing I do before my script returns the code is 0. Still deploy step fails with -12.

Updated to PS3.0 on target machine, still same error(-12).

This issue sounds like the same as mine. I have no fix for it either.

http://help.octopusdeploy.com/discussions/problems/5774-sqlpackageexe-writes-warnings-to-std-error

Hi,

Octopus detects writes to stderr as an error condition and fails the deployment. This was introduced in our new PowerShell engine. In the next version, I’ll make it an option that can be turned off.

For now, you can set a special variable called OctopusUseLegacyPowerShellEngine to true to have Octopus use the old PowerShell host, which does not use this behavior. This should allow the script to run just as it used to.

Paul

Solved my issue. Thx a lot!