量角器:在Jenkins中尝试运行时找不到命令

时间:2019-05-12 17:32:28

标签: jenkins protractor

通过执行shell脚本protractor conf.js从Jenkins运行我的Protractor测试,但出现错误:

+ export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
+ PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
+ protractor conf.js
[19:45:23] I/launcher - Running 1 instances of WebDriver
[19:45:23] I/direct - Using ChromeDriver directly...
[19:45:23] E/direct - Error code: 135
[19:45:23] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
[19:45:23] E/direct - Error: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
    at Direct.getNewDriver (/usr/local/lib/node_modules/protractor/built/driverProviders/direct.js:63:31)
    at Runner.createBrowser (/usr/local/lib/node_modules/protractor/built/runner.js:195:43)
    at q.then.then (/usr/local/lib/node_modules/protractor/built/runner.js:339:29)
    at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:796:13)
    at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:556:49
    at runSingle (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:137:13)
    at flush (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
[19:45:23] E/launcher - Process exited with error code 135
Build step 'Execute shell' marked build as failure
Finished: FAILURE

1 个答案:

答案 0 :(得分:1)

错误告诉您can't find protractor in PATH environment。您使用了全局量角器,因此需要安装一个全局量角器并将其安装位置暴露在PATH环境中。

但是我建议您使用npm install安装的本地量角器,并将其安装到/ node_modules中。使用本地量角器时,应将外壳更改为node_modules/bin/protractor conf.js

export PATH=`npm config get prefix`/bin:$PATH
webdriver-manager update <if your network behind proxy, please add option: --proxy=your_proxy_address>
protractor conf.js