我试图在Jenkins客户机中运行批处理脚本,但没有成功。 [英] I am trying to run batch script in Jenkins client machine, but not succeeded.

查看:168
本文介绍了我试图在Jenkins客户机中运行批处理脚本,但没有成功。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在我的Java程序中,我正在启动批处理脚本(.bat文件)。

我在Jenkins中遇到以下错误:

Hi all,
In my Java program I am launching batch script(.bat file).
I am facing following error in Jenkins :

FATAL: command execution failed
java.io.IOException: Cannot run program "cmd" (in directory "C:\..\Project_Name"): CreateProcess error=87, The parameter is incorrect
	at java.lang.ProcessBuilder.start(Unknown Source)
	at hudson.Proc$LocalProc.<init>(Proc.java:244)
	at hudson.Proc$LocalProc.<init>(Proc.java:216)
	at hudson.Launcher$LocalLauncher.launch(Launcher.java:815)
	at hudson.Launcher$ProcStarter.start(Launcher.java:381)
	at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1148)
	at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1113)
	at hudson.remoting.UserRequest.perform(UserRequest.java:120)
	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
	at hudson.remoting.Request$2.run(Request.java:326)
	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at hudson.remoting.Engine$1$1.run(Engine.java:62)
	at java.lang.Thread.run(Unknown Source)
	at ......remote call to VM1(Native Method)
	at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
	at hudson.remoting.UserResponse.retrieve(UserRequest.java:220)
	at hudson.remoting.Channel.call(Channel.java:781)
	at hudson.Launcher$RemoteLauncher.launch(Launcher.java:928)
	at hudson.Launcher$ProcStarter.start(Launcher.java:381)
	at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:95)
	at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:64)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
	at hudson.model.Build$BuildExecution.build(Build.java:205)
	at hudson.model.Build$BuildExecution.doRun(Build.java:162)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
	at hudson.model.Run.execute(Run.java:1738)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:98)
	at hudson.model.Executor.run(Executor.java:410)
Caused by: java.io.IOException: CreateProcess error=87, The parameter is incorrect
	at java.lang.ProcessImpl.create(Native Method)
	at java.lang.ProcessImpl.<init>(Unknown Source)
	at java.lang.ProcessImpl.start(Unknown Source)
	at java.lang.ProcessBuilder.start(Unknown Source)
	at hudson.Proc$LocalProc.<init>(Proc.java:244)
	at hudson.Proc$LocalProc.<init>(Proc.java:216)
	at hudson.Launcher$LocalLauncher.launch(Launcher.java:815)
	at hudson.Launcher$ProcStarter.start(Launcher.java:381)
	at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1148)
	at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1113)
	at hudson.remoting.UserRequest.perform(UserRequest.java:120)
	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
	at hudson.remoting.Request$2.run(Request.java:326)
	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at hudson.remoting.Engine$1$1.run(Engine.java:62)
	at java.lang.Thread.run(Unknown Source)
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE





我已将Jenkins服务作为Windows服务并尝试提供管理员对服务的权限。但我面临同样的错误。



以下是我推出批处理脚本的方法:





I have made Jenkins service as Windows service and tried with providing administrator privileges to the service. But I am facing the same error.

Following are the ways I am launching my batch script:

Desktop.getDesktop().open(new File("C:\\file1.bat"));






and

Runtime.getRuntime().exec("cmd /c C:\\file1.bat");





请有人告诉我如何解决这个问题。



Please anyone tell me how to solve this.

推荐答案

LocalProc。< init>(Proc.java: 244
at hudson.Proc
LocalProc.<init>(Proc.java:244) at hudson.Proc


LocalProc.<init>(Proc.java: 216
at hudson.Launcher
LocalProc.<init>(Proc.java:216) at hudson.Launcher


LocalLauncher.launch(Launcher.java: 815
at hudson.Launcher
LocalLauncher.launch(Launcher.java:815) at hudson.Launcher


这篇关于我试图在Jenkins客户机中运行批处理脚本,但没有成功。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆