I have set up a Jenkins job that should run Firefox. Signed in to Ubuntu with the Jenkins user, I can manually launch Firefox without any problem. However, when I run the job in Jenkins, I get :
[EnvInject] - Loading node environment variables.
Building in workspace /var/lib/jenkins/jobs/cbx4-ci/workspace
Fetching changes from the remote Git repository
Fetching upstream changes from [email protected]:cognibox/cbx4.git
Checking out Revision c90b791227b3788c2e023fd13db74ed1664428d1 (origin/master)
[EnvInject] - Executing scripts and injecting environment variables after the SCM step.
[EnvInject] - Injecting as environment variables the properties content
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
FIREFOX_BIN=/usr/bin/firefox
[EnvInject] - Variables injected successfully.
[workspace] $ /bin/sh -xe /tmp/hudson985724635788604565.sh
+ bash -ex runkarma.sh
+ node_modules/karma/bin/karma start config/karma.conf.js --reporters junit
[32mINFO [karma]: [39mKarma v0.10.9 server started at http://localhost:9876/
[32mINFO [launcher]: [39mStarting browser Firefox
[31mERROR [launcher]: [39mCannot start Firefox
[32mINFO [launcher]: [39mTrying to start Firefox again.
[31mERROR [launcher]: [39mCannot start Firefox
[32mINFO [launcher]: [39mTrying to start Firefox again.
[31mERROR [launcher]: [39mCannot start Firefox
As you can see, I have injected the environment variable to point to Firefox.
Some useful version numbers if this can help:
Jenkins 1.546 NodeJs 0.10.24 Karma 0.10.9
Edit:
It might be good to know that I had to do an operation for the jenkins user to be able to run firefox in the first place. As my main user, I had to enable other users to launch firefox by doing xhost +local:
. Without that, the jenkins user kept getting the following error.
No protocol specified
No protocol specified
No protocol specified
No protocol specified
Error: cannot open display: :0
Although this is likely a separate problem I solved, it might have incidence on the question I am asking, so I felt important to add this detail.
Got it. It turns out the problem originated from a misconception on how to run karma in the first place.
The Jenkins task was doing karma start
, with autowatch set to true. Instead, I fired up karma with autowatch false in rc.local (script ran on boot) and the Jenkins task executes karma run
instead. This solved the problem entirely.
Edit: Installing the xvnc plugin, and activating it for build works for karma start and karma run.
Edit: The problem came back when I upgraded to 14.04. The fix was to make sure the environment variables injected in the build pointed to the X11 versions.
FIREFOX_BIN=/usr/bin/X11/firefox
CHROME_BIN=/usr/bin/X11/google-chrome
Would you mind running karma with --log-level
debug and also --no-colors
so we can have a better idea of the reason why it fails?
I you also tried with another browser? I often encounter issues while running a GUI tool within Jenkins.
You might want to try running your test suite with PhantomJS (http://phantomjs.org/) just to see if a headless browser would solve the problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With