Check if agent is running as a service

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Check if agent is running as a service

Adakar
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Check if agent is running as a service

Jonathan Mackenzie
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 <[hidden email]> 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAO1vCWEALq4afNdA6ToM0SuvYd%2BW_DSFJxpEzgYuSHT%2BWhWCTw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Check if agent is running as a service

Adakar
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 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="GrGSzWWYAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jaku...@...> 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="GrGSzWWYAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkin...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/6599e4e8-fded-4ab2-8e72-0651f718d9e9%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Check if agent is running as a service

Jonathan Mackenzie
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 <[hidden email]> 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 <[hidden email]> 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/6599e4e8-fded-4ab2-8e72-0651f718d9e9%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAO1vCWGAJUwJcyJvHihM3_DJPNmkNusYNG3YiqFyTQM%2B0jwp0A%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Check if agent is running as a service

Markus Winter
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 <[hidden email]> 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 <[hidden email]> 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com.
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/6599e4e8-fded-4ab2-8e72-0651f718d9e9%40googlegroups.com.
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAO1vCWGAJUwJcyJvHihM3_DJPNmkNusYNG3YiqFyTQM%2B0jwp0A%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/1c634bd4-4866-15ec-81d6-0d3331dfadda%40gmx.de.
Reply | Threaded
Open this post in threaded view
|

Re: Check if agent is running as a service

Adakar
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 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="YoyBjMYbAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jaku...@...> 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 <[hidden email]> 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 [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com.
--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="YoyBjMYbAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkin...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/6599e4e8-fded-4ab2-8e72-0651f718d9e9%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/6599e4e8-fded-4ab2-8e72-0651f718d9e9%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/6599e4e8-fded-4ab2-8e72-0651f718d9e9%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/6599e4e8-fded-4ab2-8e72-0651f718d9e9%40googlegroups.com.
--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="YoyBjMYbAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkin...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/CAO1vCWGAJUwJcyJvHihM3_DJPNmkNusYNG3YiqFyTQM%2B0jwp0A%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAO1vCWGAJUwJcyJvHihM3_DJPNmkNusYNG3YiqFyTQM%2B0jwp0A%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CAO1vCWGAJUwJcyJvHihM3_DJPNmkNusYNG3YiqFyTQM%2B0jwp0A%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/CAO1vCWGAJUwJcyJvHihM3_DJPNmkNusYNG3YiqFyTQM%2B0jwp0A%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/7128c4f1-4e81-468d-aee2-cb8468c9b725%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Check if agent is running as a service

Daniel Beck-2


On Thu, Dec 5, 2019 at 11:26 AM Adakar <[hidden email]> wrote:
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.

That looks a bit like an XY problem (http://xyproblem.info/), if so, it would be helpful if you could provide additional context.

For example, if there's something preventing builds run from a Windows service to be completed successfully (e.g. no desktop access) in your environment, perhaps you can check for that directly rather than trying to identify whether you're running as a service? 

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAMo7PtJQi0c%2B7%2BwF7oHiJ8tDZc_6vhMpONWZvt0dPyoJ%2BBr2cw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Check if agent is running as a service

Adakar
Hi Daniel,

Thanks for the explanation and pointing this out :)

Bingo! The access to a display is mandatory for the plugin to be executed succesfully. That's exactly the reason why I wanted the plugin to stop the execution if the agent is running as a service. Although information if it is a service or not might still be useful for more detailed output.


W dniu czwartek, 5 grudnia 2019 11:57:53 UTC+1 użytkownik Daniel Beck napisał:


On Thu, Dec 5, 2019 at 11:26 AM Adakar <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="AYhC-T0lAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jaku...@...> wrote:
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.

That looks a bit like an XY problem (<a href="http://xyproblem.info/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fxyproblem.info%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFFSAswG5E4Ls8KGolh2LEC9K-E4A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fxyproblem.info%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFFSAswG5E4Ls8KGolh2LEC9K-E4A&#39;;return true;">http://xyproblem.info/), if so, it would be helpful if you could provide additional context.

For example, if there's something preventing builds run from a Windows service to be completed successfully (e.g. no desktop access) in your environment, perhaps you can check for that directly rather than trying to identify whether you're running as a service? 

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/a1563dfd-f5f7-4e8a-9cc5-c0b46c322e82%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Check if agent is running as a service

Matt Sicker
A low tech workaround for this would be using node labels to define
which nodes have the graphical environment and which ones don't.

On Fri, Dec 6, 2019 at 4:05 AM Adakar <[hidden email]> wrote:

>
> Hi Daniel,
>
> Thanks for the explanation and pointing this out :)
>
> Bingo! The access to a display is mandatory for the plugin to be executed succesfully. That's exactly the reason why I wanted the plugin to stop the execution if the agent is running as a service. Although information if it is a service or not might still be useful for more detailed output.
>
>
> W dniu czwartek, 5 grudnia 2019 11:57:53 UTC+1 użytkownik Daniel Beck napisał:
>>
>>
>>
>> On Thu, Dec 5, 2019 at 11:26 AM Adakar <[hidden email]> wrote:
>>>
>>> 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.
>>
>>
>> That looks a bit like an XY problem (http://xyproblem.info/), if so, it would be helpful if you could provide additional context.
>>
>> For example, if there's something preventing builds run from a Windows service to be completed successfully (e.g. no desktop access) in your environment, perhaps you can check for that directly rather than trying to identify whether you're running as a service?
>
> --
> 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 [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/a1563dfd-f5f7-4e8a-9cc5-c0b46c322e82%40googlegroups.com.



--
Matt Sicker
Senior Software Engineer, CloudBees

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAEot4oyOOwhrLv%2BzRBa3WiX2tKQXHmcHt6ubtHQG_rfM-Css9A%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Check if agent is running as a service

Daniel Beck


> On 6. Dec 2019, at 21:02, Matt Sicker <[hidden email]> wrote:
>
> A low tech workaround for this would be using node labels to define
> which nodes have the graphical environment and which ones don't.

I wonder whether this is something that could be done automatically in platformlabeler plugin. Probably would need a native component though.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/EB14B491-1236-4861-A9D1-749960069AAA%40beckweb.net.
Reply | Threaded
Open this post in threaded view
|

Re: Check if agent is running as a service

Mark Strasser
Do services start in headless mode? If so you could just query the system property "java.awt.headless"?

https://www.oracle.com/technical-resources/articles/javase/headless.html

Thanks
-Mark

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/f08a4dd0-c565-4baf-a8af-d09be2c565da%40googlegroups.com.