如何在 Jenkins 上使用 Xvfb 运行 无头量角器 chrome?
How do I use Xvfb to run protractor headless on Jenkins with chrome?
我正在尝试 运行 我的 protractor program from Jenkins, but since Jenkins doesn't have a display, I need to run chrome in headless mode. Since chrome doesn't have headless mode, I need to emulate a display using xvfb。
我学习了很多教程,但是当我 运行 量角器时,chrome 崩溃了。
这是我拥有的:
构建 - 执行 Shell(在 Jenkins 作业中)
#emulate display
echo "Starting xvfb on :99..."
Xvfb -ac :99 -screen 0 1280x1024x16 &
export DISPLAY=:99
echo "Checking that xvfb started ok..."
xdpyinfo -display :99 >/dev/null 2>&1 && echo "xvfb is using :99" || echo "xvfb is not using :99, it's free."
#now start my program
xvfb-run -a --server-args='-screen 0, 1024x768x16' protractor conf.js
这是我的输出:
+ echo Starting xvfb on :99...
Starting xvfb on :99...
+ export DISPLAY=:99
+ echo Checking that xvfb started ok...
Checking that xvfb started ok...
+ xdpyinfo -display :99
+ Xvfb -ac :99 -screen 0 1280x1024x16
+ echo xvfb is using :99
xvfb is using :99
[22:26:25] I/local - Starting selenium standalone server...
[22:26:25] I/launcher - Running 1 instances of WebDriver
[22:26:26] I/local - Selenium standalone server started at http://10.0.0.82:54385/wd/hub
[22:27:26] E/launcher - unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.16 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'ip-10-0-0-82', ip: '10.0.0.82', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
[22:27:26] E/launcher - WebDriverError: unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.16 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'ip-10-0-0-82', ip: '10.0.0.82', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at WebDriverError (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/error.js:27:5)
at Object.checkLegacyResponse (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/error.js:639:15)
at parseHttpResponse (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/http/index.js:538:13)
at client_.send.then.response (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/http/index.js:472:11)
at ManagedPromise.invokeCallback_ (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at asyncRun (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:2820:25)
at /jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.createSession (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
at Builder.build (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/builder.js:458:24)
at Local.DriverProvider.getNewDriver (/jenkins/workspace/myjob/src/js/node_modules/protractor/built/driverProviders/driverProvider.js:37:33)
at Runner.createBrowser (/jenkins/workspace/myjob/src/js/node_modules/protractor/built/runner.js:198:43)
at /jenkins/workspace/myjob/src/js/node_modules/protractor/built/runner.js:277:30
at _fulfilled (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:796:13)
at /jenkins/workspace/myjob/src/js/node_modules/q/q.js:604:44
at runSingle (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:137:13)
[22:27:26] E/launcher - Process exited with error code 199
我尝试过的所有方法都不断得到 Chrome failed to start: crashed
...这是我启动或配置 xvfb 的方式的问题吗?或者这是我的量角器代码的问题?堆栈跟踪对我一点帮助都没有 x.x
我建议使用 Jenkins Xvfb Plugin。它工作得非常好,而不必过多地混淆配置。
要设置作业,只需在作业开始时单击 运行 的 xvfb 选项,并在作业结束时关闭 xvfb。设置完成后,您可以在没有 xvfb 的情况下执行量角器命令:protractor conf.js
.
我正在尝试 运行 我的 protractor program from Jenkins, but since Jenkins doesn't have a display, I need to run chrome in headless mode. Since chrome doesn't have headless mode, I need to emulate a display using xvfb。
我学习了很多教程,但是当我 运行 量角器时,chrome 崩溃了。
这是我拥有的:
构建 - 执行 Shell(在 Jenkins 作业中)
#emulate display
echo "Starting xvfb on :99..."
Xvfb -ac :99 -screen 0 1280x1024x16 &
export DISPLAY=:99
echo "Checking that xvfb started ok..."
xdpyinfo -display :99 >/dev/null 2>&1 && echo "xvfb is using :99" || echo "xvfb is not using :99, it's free."
#now start my program
xvfb-run -a --server-args='-screen 0, 1024x768x16' protractor conf.js
这是我的输出:
+ echo Starting xvfb on :99...
Starting xvfb on :99...
+ export DISPLAY=:99
+ echo Checking that xvfb started ok...
Checking that xvfb started ok...
+ xdpyinfo -display :99
+ Xvfb -ac :99 -screen 0 1280x1024x16
+ echo xvfb is using :99
xvfb is using :99
[22:26:25] I/local - Starting selenium standalone server...
[22:26:25] I/launcher - Running 1 instances of WebDriver
[22:26:26] I/local - Selenium standalone server started at http://10.0.0.82:54385/wd/hub
[22:27:26] E/launcher - unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.16 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'ip-10-0-0-82', ip: '10.0.0.82', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
[22:27:26] E/launcher - WebDriverError: unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.16 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'ip-10-0-0-82', ip: '10.0.0.82', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at WebDriverError (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/error.js:27:5)
at Object.checkLegacyResponse (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/error.js:639:15)
at parseHttpResponse (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/http/index.js:538:13)
at client_.send.then.response (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/http/index.js:472:11)
at ManagedPromise.invokeCallback_ (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at asyncRun (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:2820:25)
at /jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.createSession (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
at Builder.build (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/builder.js:458:24)
at Local.DriverProvider.getNewDriver (/jenkins/workspace/myjob/src/js/node_modules/protractor/built/driverProviders/driverProvider.js:37:33)
at Runner.createBrowser (/jenkins/workspace/myjob/src/js/node_modules/protractor/built/runner.js:198:43)
at /jenkins/workspace/myjob/src/js/node_modules/protractor/built/runner.js:277:30
at _fulfilled (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:796:13)
at /jenkins/workspace/myjob/src/js/node_modules/q/q.js:604:44
at runSingle (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:137:13)
[22:27:26] E/launcher - Process exited with error code 199
我尝试过的所有方法都不断得到 Chrome failed to start: crashed
...这是我启动或配置 xvfb 的方式的问题吗?或者这是我的量角器代码的问题?堆栈跟踪对我一点帮助都没有 x.x
我建议使用 Jenkins Xvfb Plugin。它工作得非常好,而不必过多地混淆配置。
要设置作业,只需在作业开始时单击 运行 的 xvfb 选项,并在作业结束时关闭 xvfb。设置完成后,您可以在没有 xvfb 的情况下执行量角器命令:protractor conf.js
.