Jenkins on Windows and GUI Tests without RDC

我的梦境 提交于 2019-11-28 18:49:39

Your slave machines have to be at a desktop before the test can run properly. We had the same problem.

Solution was to have the test machine start up and auto-logon to the desktop. To ensure that the test would ONLY start after the desktop was available, we added a scheduled task, set to run at user login, that would launch the Jenkins slave via Java Web Start. That way, Jenkins would only see the slave once the desktop was running. After that, everything worked fine.

I have a Jenkins cluster running different kinds of GUI testing, win32, swing, selenium. They are running thousands of tests in unattended manner 24x7. Here is my solution:

  1. How to keep GUI testing alive - RDC doesn't work, the GUI applications will only function well when the RDC session is active. I've tried different ways, so don't bother to try again. Your test would broke after the RDC window is minimized or disconnected. The solution so far is install VNC Server (I am using UltraVNC) as service and make sure it is started during log on. Also make sure you don't connect to your test machine with RDC, as RDC will break VNC session. If possible connect it with VNC client as well. But that is up to you. What I do is when I need to debug something on the machine, I RDC to it and restart it to make sure #2 and #3 are set.

  2. Auto logon - there is a tool autologon.exe in SysInternalsSuite, run it on your slave

  3. Auto register slave - What you need is Swarm Plugin - https://wiki.jenkins-ci.org/display/JENKINS/Swarm+Plugin . Write a simple batch and place a shortcuts in your startup folder. Everytime your machine autologon, it is automatically registered as slave.

I actually combine #2 and #3 as a simple batch file:

autologon.exe <user> <domain> <password>
REM Here to make sure the logonCount is properly generated
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoLogonCount /t REG_DWORD /d 0xFFFF /f

start /min java -jar I:\CDC\jenkins\swarm-client-1.9-jar-with-dependencies.jar -executors 1 -fsroot c:\Jenkins -labels "Prod Win7 %ComputerName%" -master <Jenkins URL> -name farm-%ComputerName% -username <username> -password <password>

There is another way of do it without windows auto logon (works for me on few machines).

1. Go to Computer Management -> Services and Applications -> Services -> Jenkins Slave -> Properties
2. In Log On tab chose Local System account and check Allow services to interact with desktop
3. Close this windows by clicking OK, and restart the Jenkins slave service
4. Go to directory where is your test app and chose Properties on your app executable
5. On Security tab click Edit...
6. In new window click Add..
7. In new window click Locations... and chose Local computer (top most option on list), click OK
8. Put LOCAL SERVICE to white area of the window and click Check Names, click OK
9. Allow Full control for that user, click OK, close all windows

That should be everything. Let me know if it works for you.

As the other answers already stated, one needs a configuration, where the windows machine auto logons to a real user, see other answers for details. However this was not enough for me, I needed to setup a UltraVNC Server as running as service to solve the problems.

On the site is mentioned, that a login via RDP is a problem for that trick, i.e. connect with VNC or reboot after RDP access.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!