【问题标题】:windows batch command in jenkins failed詹金斯中的Windows批处理命令失败
【发布时间】:2017-02-03 04:26:00
【问题描述】:

我已经在 Docker 中设置了 Jenkins,并且能够运行一些 ANT 脚本,我现在必须运行一些“windows 批处理脚本”。我给出了一个基本命令 echo "Hello" 但我收到以下错误...我相信它期望 cmd.exe 在我的工作空间中???有人可以帮我解决这个问题吗?提前致谢。

[CI] $ cmd /c call /tmp/hudson5615964182226568321.bat
FATAL: command execution failed
java.io.IOException: Cannot run program "cmd" (in directory "/var/jenkins_home/workspace/CI"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:243)
at hudson.Proc$LocalProc.<init>(Proc.java:212)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:815)
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:779)
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:1720)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)

... 还有 15 个 构建步骤“执行 Windows 批处理命令”将构建标记为失败 完成:失败

【问题讨论】:

    标签: jenkins cmd


    【解决方案1】:

    您的 Jenkins 设置必须在 Linux 中,当您选择“Windows 批处理命令”时,该命令在 Linux 系统中不起作用。 因此,系统向您描述 cmd 无法在 Uninx 机器上执行。

    Cannot run program "cmd" (in directory "/var/jenkins_home/workspace/CI"): error=2, No such file or directory
    

    【讨论】:

    • 我明白了,shell 运行良好。感谢您的帮助
    • 我正在使用 dotnet publish 命令,它给了我错误 dotnet not found。有什么提示吗?
    【解决方案2】:

    在我的情况下,因为 jenkins 在 VM 上运行,该 VM 在 Windows 中提供基于 Linux 的系统。我们无法执行 Windows 批处理命令,因为 jenkins 正在基于 Linux 的 VM 上运行。

    所以我们必须运行 shell 脚本。 只需选择 Execute Shell 而不是 Execute Windows Batch Command

    【讨论】:

      猜你喜欢
      • 2014-09-27
      • 1970-01-01
      • 1970-01-01
      • 2018-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多