Phantomjs 在 Jenkins 上崩溃:自动配置失败

Phantomjs crashes on Jenkins: Auto configuration failed

我正在尝试 运行 我的 angular jenkins 测试用例。但是我的 PhantomJS 启动失败了。

控制台日志是:

Angular CLI: 1.6.8
Node: 8.4.0
OS: linux x64
Angular: 5.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.8
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.8
@schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0
Test cases starting........
[36m29 05 2018 08:44:10.977:DEBUG [config]: [39mLoading config /jenkins/workspace/strategic-insights/tcpa_test_integration/web/tcpa-service/src/main/resources/assets-ts/karma.conf.js
[36m29 05 2018 08:44:10.981:DEBUG [config]: [39mautoWatch set to false, because of singleRun
[36m29 05 2018 08:44:10.982:DEBUG [plugin]: [39mLoading inlined plugin (defining framework:jasmine).
[36m29 05 2018 08:44:10.983:DEBUG [plugin]: [39mLoading inlined plugin (defining launcher:Chrome, launcher:ChromeHeadless, launcher:ChromeCanary, launcher:ChromeCanaryHeadless, launcher:Chromium, launcher:ChromiumHeadless, launcher:Dartium, test).
[36m29 05 2018 08:44:10.983:DEBUG [plugin]: [39mLoading inlined plugin (defining launcher:PhantomJS).
[36m29 05 2018 08:44:10.983:DEBUG [plugin]: [39mLoading inlined plugin (defining reporter:kjhtml).
[36m29 05 2018 08:44:10.983:DEBUG [plugin]: [39mLoading inlined plugin (defining reporter:coverage-istanbul).
[36m29 05 2018 08:44:10.983:DEBUG [plugin]: [39mLoading inlined plugin (defining reporter:junit).
[36m29 05 2018 08:44:10.983:DEBUG [plugin]: [39mLoading inlined plugin (defining framework:@angular/cli, preprocessor:@angular/cli, reporter:@angular/cli, middleware:angularCliBlocker).
[36m29 05 2018 08:44:11.161:DEBUG [web-server]: [39mInstantiating middleware
[36m29 05 2018 08:44:11.162:DEBUG [reporter]: [39mTrying to load reporter: @angular/cli
[36m29 05 2018 08:44:11.163:DEBUG [reporter]: [39mTrying to load color-version of reporter: @angular/cli (@angular/cli_color)
[36m29 05 2018 08:44:11.163:DEBUG [reporter]: [39mCouldn't load color-version.
[36m29 05 2018 08:44:11.171:DEBUG [reporter]: [39mTrying to load reporter: kjhtml
[36m29 05 2018 08:44:11.172:DEBUG [reporter]: [39mTrying to load color-version of reporter: kjhtml (kjhtml_color)
[36m29 05 2018 08:44:11.172:DEBUG [reporter]: [39mCouldn't load color-version.
[36m29 05 2018 08:44:11.174:DEBUG [reporter]: [39mTrying to load reporter: junit
[36m29 05 2018 08:44:11.174:DEBUG [reporter]: [39mTrying to load color-version of reporter: junit (junit_color)
[36m29 05 2018 08:44:11.175:DEBUG [reporter]: [39mCouldn't load color-version.
[32m29 05 2018 08:44:16.960:INFO [karma]: [39mKarma v2.0.2 server started at http://0.0.0.0:9876/
[32m29 05 2018 08:44:16.960:INFO [launcher]: [39mLaunching browser PhantomJS with unlimited concurrency
[32m29 05 2018 08:44:16.976:INFO [launcher]: [39mStarting browser PhantomJS
[36m29 05 2018 08:44:16.977:DEBUG [temp-dir]: [39mCreating temp dir at /tmp/karma-12192205
[36m29 05 2018 08:44:16.981:DEBUG [launcher]: [39m/jenkins/workspace/strategic-insights/tcpa_test_integration/web/tcpa-service/src/main/resources/assets-ts/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /tmp/karma-12192205/capture.js
[31m29 05 2018 08:44:17.170:ERROR [phantomjs.launcher]: [39mAuto configuration failed
140062385686304:error:0200100D:system library:fopen:Permission denied:bss_file.c:169:fopen('/etc/ssl/openssl.cnf','rb')
140062385686304:error:2006D002:BIO routines:BIO_new_file:system lib:bss_file.c:174:
140062385686304:error:0E078002:configuration file routines:DEF_LOAD:system lib:conf_def.c:199:

[36m29 05 2018 08:44:17.172:DEBUG [launcher]: [39mProcess PhantomJS exited with code 1
[31m29 05 2018 08:44:17.173:ERROR [launcher]: [39mCannot start PhantomJS
    Auto configuration failed
140062385686304:error:0200100D:system library:fopen:Permission denied:bss_file.c:169:fopen('/etc/ssl/openssl.cnf','rb')
140062385686304:error:2006D002:BIO routines:BIO_new_file:system lib:bss_file.c:174:
140062385686304:error:0E078002:configuration file routines:DEF_LOAD:system lib:conf_def.c:199:

[31m29 05 2018 08:44:17.173:ERROR [launcher]: [39mPhantomJS stdout: 
[31m29 05 2018 08:44:17.173:ERROR [launcher]: [39mPhantomJS stderr: Auto configuration failed
140062385686304:error:0200100D:system library:fopen:Permission denied:bss_file.c:169:fopen('/etc/ssl/openssl.cnf','rb')
140062385686304:error:2006D002:BIO routines:BIO_new_file:system lib:bss_file.c:174:
140062385686304:error:0E078002:configuration file routines:DEF_LOAD:system lib:conf_def.c:199:

[36m29 05 2018 08:44:17.173:DEBUG [temp-dir]: [39mCleaning temp dir /tmp/karma-12192205
[32m29 05 2018 08:44:17.193:INFO [launcher]: [39mTrying to start PhantomJS again (1/2).
[36m29 05 2018 08:44:17.195:DEBUG [launcher]: [39mRestarting PhantomJS
[36m29 05 2018 08:44:17.195:DEBUG [temp-dir]: [39mCreating temp dir at /tmp/karma-12192205
[36m29 05 2018 08:44:17.197:DEBUG [launcher]: [39m/jenkins/workspace/strategic-insights/tcpa_test_integration/web/tcpa-service/src/main/resources/assets-ts/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /tmp/karma-12192205/capture.js /tmp/karma-12192205/capture.js
[31m29 05 2018 08:44:17.293:ERROR [phantomjs.launcher]: [39mAuto configuration failed
139712722933536:error:0200100D:system library:fopen:Permission denied:bss_file.c:169:fopen('/etc/ssl/openssl.cnf','rb')
139712722933536:error:2006D002:BIO routines:BIO_new_file:system lib:bss_file.c:174:
139712722933536:error:0E078002:configuration file routines:DEF_LOAD:system lib:conf_def.c:199:

[36m29 05 2018 08:44:17.294:DEBUG [launcher]: [39mProcess PhantomJS exited with code 1
[31m29 05 2018 08:44:17.294:ERROR [launcher]: [39mCannot start PhantomJS
    Auto configuration failed
139712722933536:error:0200100D:system library:fopen:Permission denied:bss_file.c:169:fopen('/etc/ssl/openssl.cnf','rb')
139712722933536:error:2006D002:BIO routines:BIO_new_file:system lib:bss_file.c:174:
139712722933536:error:0E078002:configuration file routines:DEF_LOAD:system lib:conf_def.c:199:

[31m29 05 2018 08:44:17.294:ERROR [launcher]: [39mPhantomJS stdout: 
[31m29 05 2018 08:44:17.295:ERROR [launcher]: [39mPhantomJS stderr: Auto configuration failed
139712722933536:error:0200100D:system library:fopen:Permission denied:bss_file.c:169:fopen('/etc/ssl/openssl.cnf','rb')
139712722933536:error:2006D002:BIO routines:BIO_new_file:system lib:bss_file.c:174:
139712722933536:error:0E078002:configuration file routines:DEF_LOAD:system lib:conf_def.c:199:

[36m29 05 2018 08:44:17.295:DEBUG [temp-dir]: [39mCleaning temp dir /tmp/karma-12192205
[32m29 05 2018 08:44:17.658:INFO [launcher]: [39mTrying to start PhantomJS again (2/2).
[36m29 05 2018 08:44:17.690:DEBUG [launcher]: [39mRestarting PhantomJS
[36m29 05 2018 08:44:17.690:DEBUG [temp-dir]: [39mCreating temp dir at /tmp/karma-12192205
[36m29 05 2018 08:44:17.692:DEBUG [launcher]: [39m/jenkins/workspace/strategic-insights/tcpa_test_integration/web/tcpa-service/src/main/resources/assets-ts/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /tmp/karma-12192205/capture.js /tmp/karma-12192205/capture.js /tmp/karma-12192205/capture.js
[31m29 05 2018 08:44:17.839:ERROR [phantomjs.launcher]: [39mAuto configuration failed
139955798914848:error:0200100D:system library:fopen:Permission denied:bss_file.c:169:fopen('/etc/ssl/openssl.cnf','rb')
139955798914848:error:2006D002:BIO routines:BIO_new_file:system lib:bss_file.c:174:
139955798914848:error:0E078002:configuration file routines:DEF_LOAD:system lib:conf_def.c:199:

[36m29 05 2018 08:44:17.839:DEBUG [launcher]: [39mProcess PhantomJS exited with code 1
[31m29 05 2018 08:44:17.839:ERROR [launcher]: [39mCannot start PhantomJS
    Auto configuration failed
139955798914848:error:0200100D:system library:fopen:Permission denied:bss_file.c:169:fopen('/etc/ssl/openssl.cnf','rb')
139955798914848:error:2006D002:BIO routines:BIO_new_file:system lib:bss_file.c:174:
139955798914848:error:0E078002:configuration file routines:DEF_LOAD:system lib:conf_def.c:199:

[31m29 05 2018 08:44:17.840:ERROR [launcher]: [39mPhantomJS stdout: 
[31m29 05 2018 08:44:17.840:ERROR [launcher]: [39mPhantomJS stderr: Auto configuration failed
139955798914848:error:0200100D:system library:fopen:Permission denied:bss_file.c:169:fopen('/etc/ssl/openssl.cnf','rb')
139955798914848:error:2006D002:BIO routines:BIO_new_file:system lib:bss_file.c:174:
139955798914848:error:0E078002:configuration file routines:DEF_LOAD:system lib:conf_def.c:199:

[36m29 05 2018 08:44:17.840:DEBUG [temp-dir]: [39mCleaning temp dir /tmp/karma-12192205
[31m29 05 2018 08:44:18.331:ERROR [launcher]: [39mPhantomJS failed 2 times (cannot start). Giving up.
[36m29 05 2018 08:44:18.332:DEBUG [karma]: [39mRun complete, exiting.
[36m29 05 2018 08:44:18.333:DEBUG [launcher]: [39mDisconnecting all browsers
Build step 'Execute shell' marked build as failure
Finished: FAILURE

我可以从日志中得出的结论是,它需要访问该文件 '/etc/ssl/openssl.cnf'。但是权限被拒绝了。

我无权更改 jenkins 服务器所在机器的权限 运行ning。需要帮助。

我遇到了同样的问题。我创建了一个 openssl.cnf 文件并将其路径添加到 OPENSSL_CONF 变量。

具体来说,在执行 'npm run test'.

之前,在您的 jenkins 脚本中添加以下行

export OPENSSL_CONF=$WORKSPACE/openssl.cnf

conf 文件不需要任何特定内容。任何示例 openssl.conf 都应该有效。