簡體   English   中英

無法在Jenkins客戶端計算機上運行批處理腳本(.bat文件)

[英]Not able to run batch script(.bat file) in Jenkins client machine

在我的Java程序中,我正在啟動批處理腳本(.bat文件)。 我面臨以下錯誤:

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服務,並嘗試為該服務提供管理員特權。 我已經更改了Jenkins客戶服務屬性,但是我遇到了同樣的錯誤。 以下是我啟動批處理腳本的方法:

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

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

要么

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

在我的情況下,所有客戶端計算機都是Windows機器。 請任何人告訴我如何解決這個問題。

檢查日志“ C:\\ .. \\ Project_Name”

此目錄無效...

因此,您還應避免根目錄“ C:\\”受Windows保護。

嘗試使用當前目錄(應該是作業工作區)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM