My intention is to customize a plugin behavior based on the fact if the 
agent is running as a service. If it does, it should stop the build. If 
not, the build should be continued. I simply want my plugin to stop builds 
which are executing on agents that are running as a Windows Service. 

W dniu czwartek, 5 grudnia 2019 09:04:25 UTC+1 użytkownik Markus Winter 
napisał:
>
> as you said you write a plugin you could just check what kind of launcher 
> is configured for the agent within your Java code
> Anyway it would help to understand why you need to know if it is running 
> as Windows Service.
> A couple of years ago we made the experience that running Windows agents 
> via Service was not very stable, we lost frequently the connection. We then 
> installed cygwin and start the agents via ssh. Since then we do not have 
> any problems anymore.
>
> On 04.12.2019 15:46, Jonathan Mackenzie wrote:
>
> Yeah you can also use 
>
> C:\WINDOWS\system32>net start | findstr "Jen"
>    Jenkins
>
> C:\WINDOWS\system32>
>
> but it sounds to me like you have a wider use case here. Maybe you'd like 
> to explain it?
>
>
>
> On Wed, Dec 4, 2019 at 2:14 AM Adakar <[email protected] <javascript:>> 
> wrote:
>
>> Hi Jonathan,
>>
>> Thank you for the answer! I know that I can check that with the help of 
>> the "sc query <name>"
>> A problem I see with this solution is the lack of knowledge about the 
>> service name. Services can be installed under custom names(e.g. 
>> jenkinsslave-D__tmp_win_Agent), right? 
>> I wonder if there is a Jenkins Java API to get information about the name 
>> or if the agent was started as a service?
>> So far I found that the plugin sees the WINSW_SERVICE_ID env variable 
>> when the agent is running as a service but I'm not sure if this check is 
>> reliable and sufficient.
>>
>> BR, Adakar
>>
>> W dniu wtorek, 3 grudnia 2019 16:56:54 UTC+1 użytkownik Jonathan 
>> Mackenzie napisał: 
>>>
>>> C:\WINDOWS\system32>sc query "jenkins"
>>>
>>> SERVICE_NAME: jenkins
>>>         TYPE               : 10  WIN32_OWN_PROCESS
>>>         STATE              : 4  RUNNING
>>>                                 (STOPPABLE, NOT_PAUSABLE, 
>>> ACCEPTS_SHUTDOWN)
>>>         WIN32_EXIT_CODE    : 0  (0x0)
>>>         SERVICE_EXIT_CODE  : 0  (0x0)
>>>         CHECKPOINT         : 0x0
>>>         WAIT_HINT          : 0x0
>>>
>>> C:\WINDOWS\system32>sc query "fred"
>>> [SC] EnumQueryServicesStatus:OpenService FAILED 1060:
>>>
>>> The specified service does not exist as an installed service.
>>>
>>>
>>> C:\WINDOWS\system32>
>>>
>>> On Tue, Dec 3, 2019 at 5:56 AM Adakar <[email protected]> wrote:
>>>
>>>> Hi There :)
>>>>
>>>> I'm working on a Jenkins plugin. I'm looking for a way to check if the 
>>>> Jenkins agent is running as a Windows service. So far my idea is to check 
>>>> if the WINSW_SERVICE_ID is set. Is there any other way? Any suggestions 
>>>> are 
>>>> highly appreciated :)
>>>>
>>>> BR, Adakar
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Jenkins Developers" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-dev/6599e4e8-fded-4ab2-8e72-0651f718d9e9%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-dev/6599e4e8-fded-4ab2-8e72-0651f718d9e9%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-dev/CAO1vCWGAJUwJcyJvHihM3_DJPNmkNusYNG3YiqFyTQM%2B0jwp0A%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-dev/CAO1vCWGAJUwJcyJvHihM3_DJPNmkNusYNG3YiqFyTQM%2B0jwp0A%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/7128c4f1-4e81-468d-aee2-cb8468c9b725%40googlegroups.com.

Reply via email to