【发布时间】:2020-01-01 11:32:26
【问题描述】:
我正在尝试使用 jenkins 对浏览器运行自动化测试,我正在使用 webdriverIO 框架。 当我使用命令提示符时它可以工作,但是当使用 jekins 触发作业时,我收到一个错误,我认为这与 jenkins 执行 shell 功能有关,
我已经下载了 nodejs 插件并将 jenkins 设置为使用自定义工作区:C:/Users/Dell/Desktop/WebDriverio/node_modules/.bin
在我输入的 shell 命令中:
npm 安装 npm 测试
喜欢这个维基:https://wiki.jenkins.io/display/JENKINS/NodeJS+Plugin
在 jenkins 系统配置中,我使用程序文件中的 npm bin 文件的路径填充了环境变量字段
这是日志输出:
Running as SYSTEM
Building in workspace C:/Users/Dell/Desktop/WebDriverio/node_modules/.bin
[.bin] $ sh -xe C:\Users\Dell\AppData\Local\Temp\jenkins4703594410706272745.sh
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
Caused: java.io.IOException: Cannot run program "sh" (in directory "C:\Users\Dell\Desktop\WebDriverio\node_modules\.bin"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:250)
at hudson.Proc$LocalProc.<init>(Proc.java:219)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:937)
at hudson.Launcher$ProcStarter.start(Launcher.java:455)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1853)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:427)
Build step 'Execute shell' marked build as failure
Finished: FAILURE
提前谢谢你
【问题讨论】:
-
我也遵循了这些说明webdriver.io/docs/jenkins.html
-
当你
npm install项目的node_modules目录下应该有一个.bin文件夹...请确认它在那里 -
是的,它就在那里,当我在 windows powershell 上执行 ./node_modules/.bin/wdio wdio.conf.js 时它可以工作
-
也许
sh是一个 linux shell 命令或缺少依赖项(我没有使用 Jenkins 的经验) -
好的,没问题,谢谢。