Can we schedule a Jenkins job to run in head mode(GUI)?

Is it possible to run the job scheduled in Jenkins to run in the GUI? like we run in a head mode in the local machine. We are recording the automation scripts written in Selenium while running on the local machine, we want to achieve this by scheduling the job in Jenkins.

I don’t have much idea, hence requesting the experts in the community. Any suggestions will be greatly appreciated.

Thanks
KiranN

Sure, as long as the Jenkins agent is running in a GUI context.

On a Windows computer, that means the Jenkins agent needs to be started from a batch file or Powershell script of a user that is logged into the Windows desktop.

On a Linux computer, that technique also works and it may be possible to use a virtual frame buffer like the one provided by the Xvfb plugin. I assume that macOS, FreeBSD, and other Unix variants have similar capabilities.

1 Like

Are there any examples/tutorials on how to best do this? We’re needing to automate an UnrealEditor-Cmd.exe with a GUI context.

I’m not aware of an example or a tutorial that shows how to do it. I have a Windows 10 agent that includes a batch file “agent.bat” on the desktop. I login to the computer and click the “agent.bat” file.

The “agent.bat” file that I use is something like this:

@ECHO ON
SET HOST=mark-pc2.markwaite.net
curl.exe -sO http://%HOST%:8080/jnlpJars/agent.jar
SET AGENT_JAR=agent.jar
SET JAVA_HOME=C:\tools\jdk-21.0.2+13
SET PATH=%JAVA_HOME%\bin;C:\tools\MinGit-2.44.0\mingw64\bin;%PATH%
set SECRET=my-agent-secret-is-here
java -jar %AGENT_JAR% -jnlpUrl http://%HOST%:8080/computer/desktop-agent/jenkins-agent.jnlp -secret %SECRET%

I haven’t bothered to add that batch file to the autostart, but that seems feasible based on this article from Microsoft answers.

1 Like