Deploy Windows Service on Windows 10 Tentacle

I’m getting an “sc.exe config failed with exit code: 1639” when deploying to a tentacle running on Windows 10, however the same deployment works fine on 8.1. It occurs with both sc config and sc create.

I’ve tried running the exact sc.exe command generated by octopus directly on Windows 10 in an elevated command prompt, and it works perfectly, so I think it could be some kind of change in WindowsService_BeforePostDeploy.ps1 permissions required to run sc on Windows 10? This is with build 10166, but it’s also been happening with previous builds.

Thanks,

Paul

The Barleycorn service already exists. It will be stopped and reconfigured.
Stopping the Barleycorn service
sc.exe config Barleycorn binPath= ““C:\program files\barleycornservice\barleycorn.winservice.exe”” DisplayName= “Barleycorn” depend= / start= delayed-auto
DESCRIPTION:
Modifies a service entry in the registry and Service Database.
USAGE:
sc config [service name] …
OPTIONS:
NOTE: The option name includes the equal sign.
A space is required between the equal sign and the value.
type= <own|share|interact|kernel|filesys|rec|adapt|userown|usershare>
start= <boot|system|auto|demand|disabled|delayed-auto>
error= <normal|severe|critical|ignore>
binPath= <BinaryPathName to the .exe file>
group=
tag= <yes|no>
depend= <Dependencies(separated by / (forward slash))>
obj= <AccountName|ObjectName>
DisplayName=
password=
Error 21:11:50
sc.exe config failed with exit code: 1639
Error 21:11:50
At C:\Program Files\Octopus Deploy\Tentacle\Scripts\Octopus.Features.WindowsSer
Error 21:11:50
vice_BeforePostDeploy.ps1:112 char:3
Error 21:11:50

  •     throw "sc.exe config failed with exit code: $LastExitCode"
    

Error 21:11:50

  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

Error 21:11:50
+ CategoryInfo : OperationStopped: (sc.exe config f…exit code:
Error 21:11:50
1639:String) [], RuntimeException
Error 21:11:50
+ FullyQualifiedErrorId : sc.exe config failed with exit code: 1639
Fatal 21:11:50
PowerShell script returned a non-zero exit code: 1
Tentacle version 2.6.5.1010

Hi Paul,

Thanks for reaching out. Desktop versions of Windows are not officially supported by us. Octopus is a server to server deployment tool, and for this reason we test it only on Server OSs. Here’s a lengthier explanation for this written by my colleague Vanessa

http://help.octopusdeploy.com/discussions/questions/3217-install-octopus-server-on-windows-7

Warm regards,

Dalmiro

Thanks for replying Dalmiro. The issue appears to be with PS 5.0 - presumably this will affect Server 2016 (where it is installed by default) and any previous Server OS’s where PS 5.0 is installed.

I’ve updated Octopus.Features.WindowsService_BeforePostDeploy.ps1 to fix the problem. No doubt you’ll resolve this officially once you test on PS 5.

Hi Paul,

Apparently this one is related to another Issue we found with PS 5, which unfortunately is on the Microsoft side. Check this thread for more info http://help.octopusdeploy.com/discussions/problems/34939

Not much we can do from our side at this point. Hopefully MS will fix this before the final Server 2016 release.

Thanks,

Dalmiro

Hi Dalmiro,

In my case it was caused by the escaped double quoting in the binPath:

binPath= ““C:\program files\barleycornservice\barleycorn.winservice.exe””

This works from a command prompt, but apparently not from PS. Stopping WindowsService_BeforePostDeploy.ps1 inserting the escaped quotes fixed the problem.

Kind Regards,

Paul

Paul - Thanks for posting your solution!

Regards,

Dalmiro

I’m having this exact same problem on Windows Server 2012 R2 Datacenter running Powershell version 5.0. Do your above responses mean that you will not support powershell 5 at this time?

Hi Pete,

We haven’t tested this again in the newer versions of Powershell 5/WMF 5 since we found the bug mentioned above. Powershell is an important piece of our architecture and its heavily used by our users, so we’ll do our best to support PS5 (which is still in preview/beta). We’ll update this thread once we test against the latest version of Powershell.

Thanks,

Dalmiro

Hi Guys ,

I’m having the same issue on windows server 2012 r2 with Powershell 5 Installed .
Is there a way to modify Octopus.Features.WindowsService_BeforePostDeploy.ps1 script on Octopus Server that’s getting deploy to Tentacles ?

I can create a PowerShell script as a workaround but I would rather modify existing script .

Regards

Mariusz

Hi Maruisz,

Thanks for reaching out. You can compile your own version of Calamari and then use it in your Octopus Instance as shown on the Readme.md of the project: https://github.com/OctopusDeploy/Calamari

Path of the script: https://github.com/OctopusDeploy/Calamari/blob/master/source/Calamari/Scripts/Octopus.Features.WindowsService_BeforePostDeploy.ps1

Or even better, you could submit a PR, and if makes sense we can add it to Calamari. Make sure though to make the script work for Powershell 5 and backwards (maybe an If (powershellversion -eq 5){ do stuff} would be the best).

Thanks,
Dalmiro

HI Dalmiro ,

I was actually testing this script and It was working on PowerShell 5 .

Is that script different then the one that is on Octopus Server 3.3.10 ?

Regards

Mariusz

Hi Maruisz,

That should be the same script yeah. Could you please send a deployment log so I can check which version of Calamari is being used during the deployment? If you don’t want that log shared in this public thread, you can send it to Support(at)Octopus(dot)com. Make sure to tell that you are coming from this thread on the email body.

Thanks,
Dalmiro

  • 1
    Using Octopus Deploy 3.2.24
    trying to promote a successful release to a new environment where this environment has PS-5 getting this error, any ETA when Octopus Deploy is going to support the built-in install windows service for Windows Server 2012R2 running PS-5?
    Thanks
    Nir

Hi Nir,

I’ve added a comment on the main github issue for this and I’m gonna bring it up to the team today/tomorrow. Try to add yourself to the watchlist of the issue below to get the latest updates.

Thanks,
Dalmiro.

Hi Dalmiro,
Thanks for this.
Yesterday I pulled the latest version of calamari (since I noticed in the release notes of 3.3.10 that there is a related fix), and tested it by building and pushing it to one of the target deployment machines which previously deployment had failed.
with the new version it works - so we’ll upgrade to 3.3.10 in the next day or 2 to finally solve this.

Thanks!