我正在尝试使用 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
在詹金斯系统配置中,我用程序文件中的 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
先感谢您