业力无法使用Jenkins和Ubuntu 12.04启动Firefox [英] Karma cannot start Firefox with Jenkins and Ubuntu 12.04
问题描述
我设置了应该运行Firefox的Jenkins作业.使用Jenkins用户登录到Ubuntu,我可以手动启动Firefox,而不会出现任何问题.但是,当我在詹金斯(Jenkins)工作时,我得到了:
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 git@bitbucket.org: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
如您所见,我注入了环境变量以指向Firefox.
As you can see, I have injected the environment variable to point to Firefox.
如果有帮助的话,一些有用的版本号:
Some useful version numbers if this can help:
詹金斯1.546 NodeJs 0.10.24 业力0.10.9
Jenkins 1.546 NodeJs 0.10.24 Karma 0.10.9
很高兴知道我必须为jenkins用户执行一项操作才能首先运行firefox.作为我的主要用户,我必须通过执行xhost +local:
来使其他用户启动firefox.否则,jenkins用户将不断出现以下错误.
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.
Jenkins任务正在执行karma start
,自动监视设置为true.相反,我在rc.local中使用autowatch false触发了业力(脚本在启动时运行),Jenkins任务改为执行karma run
.这完全解决了问题.
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.
编辑:安装 xvnc插件,并激活它以进行业力启动和业力运行的构建工作.
Edit: Installing the xvnc plugin, and activating it for build works for karma start and karma run.
编辑:当我升级到14.04时,问题又回来了.解决方法是确保在构建中注入的环境变量指向X11版本.
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
这篇关于业力无法使用Jenkins和Ubuntu 12.04启动Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!