Keep jenkins offline when user logs on to Windows

Is there a way to configure Jenkins to flag Windows slave offline when a user starts using a slave?

EDIT: By use, I mean user logs.

+6
source share
2 answers

One possible solution is to use the Prerequisite Plug-in for slaves . This allows you to add prerequisites in terms of a script:

Define a script to run on the node slave before the task runs on them. If the return status is not 0, the node will be vetoed on the execution task, and any other node will be selected, or the task will return to the queue to create a queue waiting for an available node to match its premises.

with the following script window packages:

python.exe -c "import psutil; assert len(psutil.get_users())==0" 

you will need to get psutil , but you can create something with a clean windows shell. The most obvious drawback is that we go through many systems, instead of just using those that are marked as available.

+1
source

Since a Jenkins slave device can be registered as a Windows service , one way would be to ensure that the user is not currently registered.

One could conceive Windows tasks performed regularly to check if the user is turned on, and:

  • if any, stop the service.
  • if not, (re) start the same Windows Slave Agent Jenkins service.

To check who is logged in, see “ From WindowsService, how can I find the user currently on a system with C #? ” For one way.

+1
source

All Articles