【问题标题】:Jenkins Error: Powershell Integration with JenkinsJenkins 错误:与 Jenkins 的 Powershell 集成
【发布时间】: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


【解决方案1】:

我的建议是在尝试使用 jenkins 之前先在本地检查一下。

如果您尝试使用插件或执行外部文件尝试重新检查文件路径:

系统找不到指定的文件 FATAL: command execution failed java.io.IOException: Cannot run program "powershell.exe"

powershell exe路径错误。

【讨论】:

  • 是的,你是对的,在我的系统环境变量中,powershell.exe路径不正确。谢谢
【解决方案2】:

我终于解决了。 基本上,在我的系统环境变量中,powershell.exe 路径不正确,我对其进行了更正。然后运行我的詹金斯工作,但仍然是同样的错误。 所以,我重新启动了我的系统,然后成功运行了我的 Jenkins Powershell 作业。

谢谢

【讨论】:

  • 这对我有帮助!有人在为其构建配置服务器上的软件时破坏了路径变量
【解决方案3】:

不确定这是否对其他人有帮助,但为了后代而写下来。确保您的从站正在运行并已连接。当我的 Windows Jenkins slave 断开连接时,我看到了这个错误,但我没有设置“限制此构建可以运行的位置”,因此它在我的主服务器(Linux 机器)上运行。显然它在那里找不到powershell.exe。 :D

【讨论】:

    猜你喜欢
    • 2017-12-01
    • 1970-01-01
    • 2020-05-08
    • 2014-07-08
    • 2016-06-29
    • 2014-09-29
    • 2014-11-02
    • 2014-03-12
    • 2016-02-20
    相关资源
    最近更新 更多