0

This is my first question on stackoverflow. Hope your eyes won't be bleeding too much from my English. Long story short: I can't stop my custom windows service via gitlab-runner.

What I'm trying to achieve during gitlab CI\CD is:

  • send a signal to my service to stop doing his job
  • periodically check this service status to determine whether it is stopped or not

So, I've install shell gitlab-runner locally for ease and gitlab server sees my local runner. My windows service has name in the following format: "My.Service.Name".

gitlab-ci.yml contains job <my_job_name> with following command inside script section sc.exe queryex My.Service.Name (trying to get service status).

Command execution gives me error [SC] EnumQueryServicesStatus:OpenService FAILED 1060: The specified service does not exist as an installed service. Basically, sc.exe stop My.Service.Name also failed with error [SC] OpenService FAILED 1060: The specified service does not exist as an installed service.

My service was created this way: sc create My.Service.Name binPath= "path\to\exe\My.Service.Name.exe -service" DisplayName= My.Service.Name start= delayed-auto depend= MSMQ. Local query result of sc.exe queryex My.Service.Name call.

I was already checked this:

  • my service exists and has same service and display names in services.msc (My.Service.Name)
  • service name didn't contain any spaces (in case of missing quotes)
  • simple command sc.exe queryex (via gitlab-runner) gives me not all services, that I can see in services.msc locally
  • alternative command also not giving me all services from services.msc Get-Service -ComputerName . (via gitlab-runner)
  • same commands executed locally gives me desired result via both sc.exe sc.exe queryex My.Service.Name and Get-Service in PowerShell Get-Service | where {$_.name -like "*My.Service.Name*"} or Get-Service -ComputerName .
  • both services gitlab-runner and My.Service.Name are running with my local administrator account
  • local run gitlab-runner.exe exec shell my_job_name gives me desired result also, so I can query service information and even stop service
  • based on similar questions, I also checked that windows RPC services are enabled and currently running

So, why some services, including my service, are not listed in results of sc.exe and Get-Service (via gitlab-runner)? I suspect some permission issues here. Any help will be appreciated.

Mikhail 89
  • 26
  • 4

1 Answers1

1

I finally get what is wrong - I messed up with gitlab-ci.yml job tags and in fact, another gitlab-runner processed incoming build. Now it's working as expected.

Mikhail 89
  • 26
  • 4