【发布时间】:2016-03-28 12:51:31
【问题描述】:
我正在尝试将 PowerShell 与 Jenkins 集成。我发现很难解决此错误,因为我的 PowerShell 脚本作业失败,如下所示。
[own-machine-powershell-job] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Windows\TEMP\hudson3566059468296731803.ps1'"
该系统找不到指定的文件
致命:命令执行失败
java.io.IOException: Cannot run program "powershell.exe" (in directory "C:\jenkins\workspace\own-machine-powershell-job"): CreateProcess error=2, 系统找不到指定的文件
在 java.lang.ProcessBuilder.start(未知来源)
在 hudson.Proc$LocalProc.(Proc.java:244)
在 hudson.Proc$LocalProc.(Proc.java:216)
在 hudson.Launcher$LocalLauncher.launch(Launcher.java:816)
在 hudson.Launcher$ProcStarter.start(Launcher.java:382)
在 hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1149)
在 hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1114)
在 hudson.remoting.UserRequest.perform(UserRequest.java:120)
在 hudson.remoting.UserRequest.perform(UserRequest.java:48)
在 hudson.remoting.Request$2.run(Request.java:326)
在 hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
在 java.util.concurrent.FutureTask.run(未知来源)
在 java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源)
在 java.util.concurrent.ThreadPoolExecutor$Worker.run(未知来源)
在 hudson.remoting.Engine$1$1.run(Engine.java:62)
在 java.lang.Thread.run(未知来源)
at ......远程调用 Powershell-Job(Native Method)
在 hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
在 hudson.remoting.UserResponse.retrieve(UserRequest.java:220)
在 hudson.remoting.Channel.call(Channel.java:781)
在 hudson.Launcher$RemoteLauncher.launch(Launcher.java:929)
在 hudson.Launcher$ProcStarter.start(Launcher.java:382)
在 hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:97)
在 hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
在 hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
在 hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:785)
在 hudson.model.Build$BuildExecution.build(Build.java:205)
在 hudson.model.Build$BuildExecution.doRun(Build.java:162)
在 hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
在 hudson.model.Run.execute(Run.java:1741)
在 hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
在 hudson.model.ResourceController.execute(ResourceController.java:98)
在 hudson.model.Executor.run(Executor.java:408)
原因:java.io.IOException: CreateProcess error=2, 系统找不到指定的文件
在 java.lang.ProcessImpl.create(本机方法)
在 java.lang.ProcessImpl.(未知来源)
在 java.lang.ProcessImpl.start(未知来源)
在 java.lang.ProcessBuilder.start(未知来源)
在 hudson.Proc$LocalProc.(Proc.java:244)
在 hudson.Proc$LocalProc.(Proc.java:216)
在 hudson.Launcher$LocalLauncher.launch(Launcher.java:816)
在 hudson.Launcher$ProcStarter.start(Launcher.java:382)
在 hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1149)
在 hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1114)
在 hudson.remoting.UserRequest.perform(UserRequest.java:120)
在 hudson.remoting.UserRequest.perform(UserRequest.java:48)
在 hudson.remoting.Request$2.run(Request.java:326)
在 hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
在 java.util.concurrent.FutureTask.run(未知来源)
在 java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源)
在 java.util.concurrent.ThreadPoolExecutor$Worker.run(未知来源)
在 hudson.remoting.Engine$1$1.run(Engine.java:62)
在 java.lang.Thread.run(未知来源)
构建步骤“Windows PowerShell”将构建标记为失败
完成:失败
【问题讨论】:
-
我看到过其他关于同一问题的类似帖子,但无法解决该问题。提前致谢
-
我几乎没有使用 Jenkins 的经验,也没有使用 Windows 上的 Jenkins 的经验,但我的第一个猜测是这是一个 PATH 问题。
powershell.exe位于C:\Windows\System32\WindowsPowerShell\v1.0。您是否尝试使用完整路径调用它? -
您应该展示如何尝试在 Jenkins 中执行脚本。 Jenkins 构建步骤的屏幕截图应该会有所帮助。
标签: powershell jenkins