当前位置: 首页 > 知识库问答 >
问题:

获取java.io.ioException:CreateProcess error=2,系统无法找到jenkins中指定的文件

姜志
2023-03-14

当运行下面的jenkins管道代码时,我得到了错误。我在指定的位置找不到文件,这是一个错误。所以我尝试了很多方法,但得到了同样的错误。

即使有人知道如何写jenkins文件,也可以评论它,或者如果你有任何网址,也可以在评论中发布。这会有很大帮助的

java.io.IOException: CreateProcess error=2, The system cannot find the file specified
        at java.base/java.lang.ProcessImpl.create(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:487)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:154)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
        at hudson.Proc$LocalProc.<init>(Proc.java:252)
        at hudson.Proc$LocalProc.<init>(Proc.java:221)
        at hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
        at hudson.Launcher$ProcStarter.start(Launcher.java:508)
        at org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:236)
        at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:103)
        at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:320)
        at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:319)
        at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:193)
        at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
        at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:163)
        at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
        at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:158)
        at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:161)
        at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165)
        at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
        at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
    Caused: java.io.IOException: Cannot run program "nohup" (in directory "C:\Users\sambe\.jenkins\workspace\KaratePipeLine"): CreateProcess error=2, The system cannot find the file specified
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
        at hudson.Proc$LocalProc.<init>(Proc.java:252)
        at hudson.Proc$LocalProc.<init>(Proc.java:221)
        at hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
        at hudson.Launcher$ProcStarter.start(Launcher.java:508)
        at org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:236)
        at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:103)
        at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:320)
        at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:319)
        at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:193)
        at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
        at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:163)
        at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
        at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:158)
        at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:161)
        at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165)
        at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
        at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
        at WorkflowScript.run(WorkflowScript:14)
        at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.delegateAndExecute(ModelInterpreter.groovy:137)
        at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.executeSingleStage(ModelInterpreter.groovy:661)
        at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.catchRequiredContextForNode(ModelInterpreter.groovy:395)
        at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.catchRequiredContextForNode(ModelInterpreter.groovy:393)
        at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.executeSingleStage(ModelInterpreter.groovy:660)
        at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.evaluateStage(ModelInterpreter.groovy:288)
        at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.toolsBlock(ModelInterpreter.groovy:539)
        at ___cps.transform___(Native Method)
        at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
        at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
        at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
        at jdk.internal.reflect.GeneratedMethodAccessor195.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
        at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
        at com.cloudbees.groovy.cps.Next.step(Next.java:83)
        at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
        at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
        at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
        at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
        at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
        at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
        at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
        at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276)
        at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
        at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
pipeline{
    agent any
    tools{
        maven 'Maven'
    }
    stages{
        stage("SCM Checkout"){
            steps{
            git 'https://github.com/samben01/KarateWithJenkins.git'
            }
        }
        stage("Maven Build"){
            steps{
                sh 'mvn clean package'
            }
        }
    }
}

我已经附上了上面的所有数据,如果有人知道答案,请回答问题

共有1个答案

万俟玉书
2023-03-14

您似乎正在运行在Windows代理上执行Shell块的作业。如果您打算使用Shell块或将Shell块更改为bat并在Windows代理上运行,请尝试查看是否可以在Linux代理上运行此命令,而不是使用“代理任何”。

 类似资料:
  • 问题内容: 我正在用Java编写一个程序,该程序将执行winrar并将一个供我使用的jar文件解压缩到该文件夹​​中。我的Java代码是这样的 执行此操作时,出现此错误 谁能告诉我为什么会遇到这样的问题。为了使其起作用,我需要在代码中进行哪些更改? 问题答案: 假设位于中,则能够找到它,如果没有,则需要提供到它的完全限定路径,例如,假设已安装在其中,则需要使用类似… 就个人而言,我建议您使用它,因

  • 问题内容: 我正在制作一个打开并读取文件的程序。这是我的代码: 但是当我跑步时,出现以下错误: 我和位于同一目录中的以下位置: 我想知道我在做什么错? 问题答案: 我已经复制了您的代码,并且运行正常。 我怀疑您在hello.txt的实际文件名中仅存在一些问题,或者您在错误的目录中运行。考虑通过@ Eng.Fouad建议的方法进行验证

  • 我是编程新手。我最近尝试下载开源软件的源代码并设置环境。但是,当我第一次尝试运行构建时,我看到以下问题: 执行失败:Java . io . io异常:无法运行程序“unzip”(在目录中)....\"): CreateProcess error=2,系统找不到java.lang.ProcessBuilder.start中指定的文件 有什么解决这个问题的技巧吗? 据我所知,它无法成为文件: 在哪里查

  • 问题内容: 我在Windows和Linux中运行的Pydub模块有问题。当我尝试这样打开mp3文件时: 控制台向我显示下一条消息: WindowsError:[错误2]系统找不到指定的文件 但是…我将文件(test.mp3)与脚本放在同一文件夹中,名称正确。 为什么我有这个问题?(在Linux中,具有相同的错误) 问题答案: 确保已安装 http://www.ffmpeg.org/。您可以从此官方

  • 问题内容: 我有一个名为 的文件。 它与我的文件位于同一目录中。 但是,当我尝试通过以下代码访问它时,找不到此文件,发生错误: 这是我的代码: 问题答案: 直接将word.txt作为项目根文件夹的子级和src的对等方放置 免责声明:我想解释一下为什么这种方法适用于这种特殊情况,以及为什么它可能不适用于其他情况。 工作原理: 使用或任何其他变体时,你正在文件系统上相对于“工作目录”查找文件。工作目录

  • 问题内容: 我收到以下错误 但我可以肯定地说,我已经在src,bin和根目录下创建了一个in.txt文件。我还尝试在主要参数中指定完整目录,但仍然无法正常工作。为什么Eclipse不选择它? 问题答案: 我获取了您的代码,并使用以下命令行参数执行了该代码: 它完全没有问题。检查您的命令行。