3

I am trying to run karma as a grunt task on a Ubuntu 12.04 machine in Jenkins CI. The issue I am running into is that karma will not open Chrome and gives the following error:

Started by GitHub push by spencerapplegate
[EnvInject] - Loading node environment variables.
Building in workspace /var/lib/jenkins/jobs/rescour-roomba master/workspace
Checkout:workspace / /var/lib/jenkins/jobs/rescour-roomba master/workspace - hudson.remoting.LocalChannel@7b41ce14
Using strategy: Default
Last Built Revision: Revision ee61ceea1b8728e90b01db04a1813284a524caed (origin/master)
Fetching changes from 1 remote Git repository
Fetching upstream changes from origin
Commencing build of Revision d3ed5ffd7c7b7a707bd9310c5bce09242e1faced (origin/master)
Checking out Revision d3ed5ffd7c7b7a707bd9310c5bce09242e1faced (origin/master)
[EnvInject] - Executing scripts and injecting environment variables after the SCM step.
[EnvInject] - Injecting as environment variables the properties content
CHROME_BIN=/opt/google/chrome/

[EnvInject] - Variables injected successfully.
[workspace] $ /bin/sh -xe /tmp/hudson5570746814297674358.sh
+ sudo npm install
+ sudo grunt buildProd
Loading "express.js" tasks...
[31mERROR[39m[31m>> [39mError: Cannot find module 'temp'

[4mRunning "clean:build" (clean) task[24m
Cleaning ".tmp"...[32mOK[39m
Cleaning "build/app"...[32mOK[39m
Cleaning "build/app-config"...[32mOK[39m
Cleaning "build/components"...[32mOK[39m
Cleaning "build/img"...[32mOK[39m
Cleaning "build/index.html"...[32mOK[39m
Cleaning "build/scripts"...[32mOK[39m
Cleaning "build/src"...[32mOK[39m
Cleaning "build/styles"...[32mOK[39m

[4mRunning "copy:local" (copy) task[24m
Created [36m370[39m directories, copied [36m2260[39m files

[4mRunning "compass:prod" (compass) task[24m
[31m[0m[32mdirectory[0m .tmp/styles/ 
[31m[0m[32m   create[0m .tmp/styles/main.css (1.732s)
Compilation took 1.784s

[4mRunning "template:prod" (template) task[24m

[4mRunning "clean:template" (clean) task[24m
Cleaning ".tmp/index.html.template"...[32mOK[39m

[4mRunning "karma:unit" (karma) task[24m
[36m[2013-10-07 10:07:51.709] [DEBUG] config - [39mautoWatch set to false, because of singleRun
[32mINFO [karma]: [39mKarma server started at http://localhost:8079/
[32mINFO [launcher]: [39mStarting browser Chrome
[31mERROR [launcher]: [39mCannot start Chrome        

[32mINFO [launcher]: [39mTrying to start Chrome again.
[31mERROR [launcher]: [39mCannot start Chrome        

[32mINFO [launcher]: [39mTrying to start Chrome again.
[31mERROR [launcher]: [39mCannot start Chrome        

[33mWarning: Task "karma:unit" failed. Use --force to continue.[39m

[31mAborted due to warnings.[39m
Build step 'Execute shell' marked build as failure
SSH: Current build result is [FAILURE], not going to run. 
Finished: FAILURE

I have set CHROME_BIN=/opt/google/chrome and it seems like it has no issue finding the executable.

Other approaches I have taken (all unsuccessful) are: -> Create shell script to open chrome as root with flag --user-data-dir -> Copy all chrome files to a jenkins subdirectory /home/jenkins/opt/google/chrome -> Change ownership of all chrome files in /opt/google/chrome to jenkins

The other oddity is that when I log into the machine as the jenkins user, chrome runs the tests fine.

Please let me know if there is any more info I need to provide. Thanks

4

2 回答 2

4

我有同样的问题。为 Jenkins ( https://wiki.jenkins-ci.org/display/JENKINS/Xvnc+Plugin )安装xvnc插件后,问题消失了。

于 2014-01-20T10:04:51.147 回答
2

对我来说,这是对 karma start 与 karma run 的误用。您需要运行 karma 服务器,并在 jenkins 作业中使用 karma run。在这里查看我的问题和答案。

编辑:乐虎的答案适用于启动/运行。

于 2014-01-20T21:27:57.003 回答