[英]How to solve Error: spawn EACCES on Jenkins when running Karma?
我已經設置了AWS Codepipeline。
該管道使用Git作為源,Jenkins用於測試,使用EC2實例進行部署。
該項目基於Angular Class的Angular Starter 。 因此,它使用Karma進行單元測試。
Jenkins服務在Ubuntu 16.04上運行。
Karma使用Headless Chrome進行測試。
問題是我在Jenkins上運行測試時遇到了以下錯誤:
[31m07 05 2017 14:30:35.779:ERROR [karma]: [39m{ Error: spawn EACCES
at exports._errnoException (util.js:1050:11)
at ChildProcess.spawn (internal/child_process.js:319:11)
at exports.spawn (child_process.js:378:9)
at spawnWithoutOutput (/var/lib/jenkins/workspace/ExampleTask/node_modules/karma/lib/launchers/process.js:168:24)
at Object.ProcessLauncher._execCommand (/var/lib/jenkins/workspace/ExampleTask/node_modules/karma/lib/launchers/process.js:76:21)
at Object.ProcessLauncher._start (/var/lib/jenkins/workspace/ExampleTask/node_modules/karma/lib/launchers/process.js:33:10)
at Object.<anonymous> (/var/lib/jenkins/workspace/ExampleTask/node_modules/karma/lib/launchers/process.js:19:10)
at emitOne (events.js:101:20)
at Object.emit (events.js:191:7)
at Object.BaseLauncher.start (/var/lib/jenkins/workspace/ExampleTask/node_modules/karma/lib/launchers/base.js:42:10)
at Object.j (/var/lib/jenkins/workspace/ExampleTask/node_modules/karma/lib/launcher.js:116:17)
at Object.setTimeout.bind.j (/var/lib/jenkins/workspace/ExampleTask/node_modules/qjobs/qjobs.js:143:18)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5) code: 'EACCES', errno: 'EACCES', syscall: 'spawn' }
我已經做了一些研究,結果如下:
到目前為止我嘗試過的:
permission denied /root/.nvm
npm日志文件輸出如下:
0 info it worked if it ends with ok
1 verbose cli [ '/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.10.0/bin/node',
1 verbose cli '/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.10.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'test' ]
2 info using npm@4.2.0
3 info using node@v7.10.0
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle example@0.0.1~pretest: example@0.0.1
6 silly lifecycle example@0.0.1~pretest: no script for pretest, continuing
7 info lifecycle example@0.0.1~test: example@0.0.1
8 verbose lifecycle example@0.0.1~test: unsafe-perm in lifecycle true
9 verbose lifecycle example@0.0.1~test: PATH: /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.10.0/lib/node_modules/npm/bin/node-gyp-bin:/var/lib/jenkins/workspace/ExampleTask/node_modules/.bin:/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.10.0/lib/node_modules/npm/bin/node-gyp-bin:/var/lib/jenkins/workspace/ExampleTask/node_modules/.bin:/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.10.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin
10 verbose lifecycle example@0.0.1~test: CWD: /var/lib/jenkins/workspace/ExampleTask
11 silly lifecycle example@0.0.1~test: Args: [ '-c', 'npm run lint && karma start' ]
12 silly lifecycle example@0.0.1~test: Returned: code: 1 signal: null
13 info lifecycle example@0.0.1~test: Failed to exec test script
14 verbose stack Error: example@0.0.1 test: `npm run lint && karma start`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.10.0/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:194:7)
14 verbose stack at ChildProcess.<anonymous> (/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.10.0/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:194:7)
14 verbose stack at maybeClose (internal/child_process.js:899:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid example@0.0.1
16 verbose cwd /var/lib/jenkins/workspace/ExampleTask
17 error Linux 4.4.0-1016-aws
18 error argv "/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.10.0/bin/node" "/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.10.0/bin/npm" "run" "test"
19 error node v7.10.0
20 error npm v4.2.0
21 error code ELIFECYCLE
22 error errno 1
23 error example@0.0.1 test: `npm run lint && karma start`
23 error Exit status 1
24 error Failed at the example@0.0.1 test script 'npm run lint && karma start'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the example package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error npm run lint && karma start
24 error You can get information on how to open an issue for this project with:
24 error npm bugs example
24 error Or if that isn't available, you can get their info via:
24 error npm owner ls example
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]
Jenkins節點插件沒有執行特定任務的正確權限。 通過基本安裝節點提供Jenkins用戶sudo權限,然后使用命令“sudo command”。
我遇到了類似的問題,可以通過安裝Chrome來解決問題。 請注意,您可能還必須設置CHROME_BIN環境變量。
供參考:我在Docker中運行Jenkins。 js項目安裝了chromedriver作為依賴項,我將CHROME_BIN設置為chromedriver並收到了你提到的相同問題(我的堆棧跟蹤如下)。 希望這是一些幫助或至少幫助你移動,祝你好運。
03 01 2018 02:01:20.288:ERROR [karma]: { Error: spawn EACCES
at exports._errnoException (util.js:1020:11)
at ChildProcess.spawn (internal/child_process.js:328:11)
at exports.spawn (child_process.js:370:9)
at spawnWithoutOutput (/var/jenkins_home/jobs/oh2.0 test/workspace/node_modules/karma/lib/launchers/process.js:168:24)
at Object.ProcessLauncher._execCommand (/var/jenkins_home/jobs/oh2.0 test/workspace/node_modules/karma/lib/launchers/process.js:76:21)
at Object.ProcessLauncher._start (/var/jenkins_home/jobs/oh2.0 test/workspace/node_modules/karma/lib/launchers/process.js:33:10)
at Object.<anonymous> (/var/jenkins_home/jobs/oh2.0 test/workspace/node_modules/karma/lib/launchers/process.js:19:10)
at emitOne (events.js:101:20)
at Object.emit (events.js:188:7)
at Object.BaseLauncher.start (/var/jenkins_home/jobs/oh2.0 test/workspace/node_modules/karma/lib/launchers/base.js:42:10)
at Object.j (/var/jenkins_home/jobs/oh2.0 test/workspace/node_modules/karma/lib/launcher.js:116:17)
at Object.setTimeout.bind.j (/var/jenkins_home/jobs/oh2.0 test/workspace/node_modules/qjobs/qjobs.js:143:18)
at ontimeout (timers.js:386:11)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5) code: 'EACCES', errno: 'EACCES', syscall: 'spawn' }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.