【问题标题】:Karma cannot launch Chrome for Jenkins in Ubuntu 12.04Karma 无法在 Ubuntu 12.04 中启动 Chrome for Jenkins
【发布时间】:2013-10-07 16:16:22
【问题描述】:

我正在尝试在 Jenkins CI 中的 Ubuntu 12.04 机器上运行 karma 作为一项繁重的任务。我遇到的问题是 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 用户身份登录并成功运行,包括为 bin 设置路径),但在我的情况下它是 firefox。你在这方面有没有成功。如果是这样,我建议发布我很乐意 +1 的答案。

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


【解决方案1】:

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

【讨论】:

  • 这对我不起作用。我已经有了它,甚至尝试过卸载安装。虽然我的业力运行正常,但我真的更希望业力开始工作。您使用的是 karma run 还是 karma start ? Ubuntu ?
  • 哦。必须在构建配置中勾选 xvnc 选项。这应该是正确的答案。
【解决方案2】:

对我来说,这是对 karma start 与 karma run 的误用。您需要运行 karma 服务器,并在 jenkins 作业中使用 karma run。请参阅我的问答here

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-14
    • 1970-01-01
    • 2013-01-07
    • 1970-01-01
    • 2012-12-03
    • 1970-01-01
    • 2012-12-20
    相关资源
    最近更新 更多