Good morning, group-
We are a small tech company with a sizeable Web Portal for our users.
Over the past 2 years, I have written a number of Python/Selenium scripts that exercise the Portal for regression/soak testing.
I am running Jenkins locally on my Linux laptop. My python scripts are also local to this machine. The scripts run fine from the command line, but if I try to run them as a “Build step” in Jenkins, they always fail. I can’t even get Chrome to launch from Jenkins- Adding a Build Step of type “Execute Shell” with just ‘google-chrome’ as the command Jenkins complains that it doesn’t have a display.
I feel that I am missing something very basic. Can anyone help me get Jenkins to just launch a Chrome browser window on my desktop?
Thank you in advance for any advice.
Console output from just attempting to launch Chrome:
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/Test
[Test] $ /bin/bash -xe /tmp/jenkins3430379009666771726.sh
- export DISPLAY=:0
No protocol specified
[32153:32153:1208/161539.188118:ERROR:ozone_platform_x11.cc(238)] Missing X server or $DISPLAY
[32153:32153:1208/161539.188147:ERROR:env.cc(255)] The platform failed to initialize. Exiting.
Build step ‘Execute shell’ marked build as failure
They get wordier if I’m trying to initialize Selenium as well.
Python scripts just don’t run the way it should- dependencies and modules that are installed on my machine report that they are missing when run through Jenkins.
There’s a disconnect somewhere. It feels like Jenkins is running in it’s own environment rather than using the resources available on my machine. I haven’t been able to locate a basic, simple, written (as in not YouTube), step-by-step guide to getting Jenkins configured and running on a local machine.
This sounds like an environment variables type thing. Jenkins tries to run in a clean environment situation and doesn’t copy all the environmental variables from the host system. You’ll probably want to either set up those on the agent (/computer/ url) or job level.
That is saying its not connected to your display manager. You can either point it at your local one but that would mean potentially someone could mess with things during the test. I recommend xvfb which runs everything in a null environment, so it won’t get any external input from your mouse and keyboard
Thanks very much Halkeye- I’ll look into Xvfb.
In this stage of my Jenkins journey (day 3), I’m more concerned with “making it work” than ensuring no one monkeys with it. Can you perhaps explain how to point Chrome to my local display manager? That is something I can build on.
Is there a good resource on getting the environment variables set up properly? Ideally something that explains the “Whys” as well as the “Whats”.
Those are both questions well outside of jenkins.
How to start a GUI software on a remote Linux PC via SSH - Ask Ubuntu probably gives you more information on how to run software in a terminal/account that isn’t the main logged running the gui (even if usernames are the same)