google-chrome - Karma 无法在 Ubuntu 12.04 中为 Jenkins 启动 Chrome

标签 google-chrome jenkins ubuntu-12.04 gruntjs karma-runner

我正在尝试在 Jenkins CI 中的 Ubuntu 12.04 机器上将 karma 作为 grunt 任务运行。我遇到的问题是 karma 无法打开 Chrome 并出现以下错误:

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

我已经设置了 CHROME_BIN=/opt/google/chrome,它似乎可以毫无问题地找到可执行文件。

我采取的其他方法(均未成功)是: -> 创建 shell 脚本以使用标志 --user-data-dir 以 root 身份打开 chrome -> 将所有 chrome 文件复制到 jenkins 子目录/home/jenkins/opt/google/chrome -> 将/opt/google/chrome 中所有 chrome 文件的所有权更改为 jenkins

另一个奇怪的是,当我以 jenkins 用户身份登录机器时,chrome 运行测试正常。

如果我需要提供更多信息,请告诉我。谢谢

最佳答案

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

关于google-chrome - Karma 无法在 Ubuntu 12.04 中为 Jenkins 启动 Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19229725/

相关文章:

google-chrome - CSS盒模型问题: box-sizing + 100% height + border + inline-block

javascript - 断点调试缩小/损坏/编译变量

jenkins - Jenkins 电子邮件扩展插件发送的电子邮件未收到?

jenkins - 在 Jenkins 中,我可以在其他配置字段中使用参数值吗?

nginx - Rails 生产 - 新部署后所有图片都损坏了

html - 表格填充在 chrome 中不起作用

javascript - document.location.reload(true) 在 chrome 中取消

python - 无法在 Jenkins 中运行 python 脚本

linux - Ubuntu Upstart 无法停止/重启 Graphite 碳缓存

glassfish-3 - Glassfish updatetool linux 64位问题