Jenkins windows slave service does not interact wi

2019-01-14 12:46发布

I have followed this guide to install a jenkins slave on windows 8 as a service:

https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Windows+service#InstallingJenkinsasaWindowsservice-InstallSlaveasaWindowsservice%28require.NET2.0framework%29

I need to run a job that interact with the desktop (run an application that opens a browser etc.). So after I have installed the slave as a service (running jnlp downloaded from the master) I have changed the service "Log on" to "Allow to interact with display".

For some reason its only possible to enable this for the "Local System account" even though its recommended to run the service as a specified user, eg. jenkins.

But nothing happens when I execute the job, the browser is not opened. If I instead stop the service and just launch the slave through the jnlp file the job runs fine - the browser is opened.

Anybody had any luck interacting with the desktop when running a jenkins windows slave as a service?

7条回答
欢心
2楼-- · 2019-01-14 13:06

Please check the services (@ TestNode) make sure the "Interactive Services Detection" service is STARTED, by default the startup type is set to Manual, you may like to set it to automatic as well.

enter image description here

After service started, when you run your test in the Test Node, you will see something like the below: enter image description here

Click on it and choose view the message

enter image description here

You will see the activities happen there. Hope this helps :D

Note: If login with other account and cannot view the Interative Services Detection prompt, restart the service again.

查看更多
虎瘦雄心在
3楼-- · 2019-01-14 13:07

Consider running the Java slave server directly at startup and then using something to monitor and restart should the server go down (e.g., Kiwi Restarter).

查看更多
霸刀☆藐视天下
4楼-- · 2019-01-14 13:07

Make sure that Desktop folders are created as such:

  • %WINDOWS%/System32/config/systemprofile/Desktop
  • %WINDOWS%/SystemWOW64/config/systemprofile/Desktop

Presence of those can sometimes be mandatory while running some Java software as a Service.

查看更多
趁早两清
5楼-- · 2019-01-14 13:09

To Solve it set Windows Auto Logon as I explain here: https://serverfault.com/questions/269832/windows-server-2008-automatic-user-logon-on-power-on/606130#606130

Then create a startup batch for Jenkins slave (place it in Jenkins directory), which will launch it's console on desktop, and will allow GUI jobs to run:

java -jar slave.jar -jnlpUrl http://{Your Jenkins Server}:8080/computer/{Your Jenkins Node}/slave-agent.jnlp

(the slave.jar you can download from http://{Your Jenkins Server}:8080/jnlpJars/slave.jar)

EDIT : If you're getting black screenshots (when using Selenium or Sikuli, for example), create a batch file that disconnects Remote Desktop, instead of closing the RDP session with the regular X button:

%windir%\system32\tscon.exe %SESSIONNAME% /dest:console 
查看更多
倾城 Initia
6楼-- · 2019-01-14 13:24

My Jenkins Service runs as user "jenkins" and all I did was to create Desktop folders in: C:\Windows\system32\config\systemprofile\desktop and if 64 bit Windows also in C:\Windows\SysWOW64\config\systemprofile\desktop - then it runs perfectly.

查看更多
Emotional °昔
7楼-- · 2019-01-14 13:29

Services run since Vista in Session 0 and the first user is now in Session 1. So you can't interact any longer. This is called Session 0 Isolation.

Microsoft explains this here and here. You have to use 2nd Program which uses IPC to communicate to the Service.

查看更多
登录 后发表回答