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

詹金斯管道bash执行

元望
2023-03-14
pipeline {
    agent any 
    stages {
        stage('Stage 1') {
            steps {
                sh 'echo "egfr"' 
            }
        }
    }
}
java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    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:249)
    at hudson.Proc$LocalProc.<init>(Proc.java:218)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:929)
    at hudson.Launcher$ProcStarter.start(Launcher.java:449)
    at org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:186)
    at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:71)
    at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:176)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:229)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:153)
    at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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:157)
    at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:133)
    at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129)
    at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
Caused: java.io.IOException: Cannot run program "nohup" (in directory "C:\Program Files (x86)\Jenkins\workspace\p"): CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    at hudson.Proc$LocalProc.<init>(Proc.java:249)
    at hudson.Proc$LocalProc.<init>(Proc.java:218)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:929)
    at hudson.Launcher$ProcStarter.start(Launcher.java:449)
    at org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:186)
    ...

我已经尝试将Shell可执行文件设置为C:\windows\system32\cmd.exe和C:\cygwin64\bin\sh.exe,但是我遇到了同样的错误。我怎样才能解决这个问题?

共有1个答案

庄萧迟
2023-03-14

这是一个有点晚,但为了将来我会添加答案,因为我有类似的问题。

在windows上,您不能执行“sh”管道步骤。既不是你,也不是jenkins插件(有些确实尝试。exp:docker管道)。您可以使用BatPowerShell或尝试在windows上启用sh(对我来说很有效):

1)安装GIT Bash

 类似资料:
  • 问题内容: 已解决 :感谢S.Richmond的以下答复我需要取消所有类型的存储映射,这意味着将变量和使用后作废。 附加 :搜索此错误的人员可能有兴趣使用Jenkins管道步骤- 在此处查找更多信息。 我正在尝试使用Jenkins Pipeline从用户那里获取输入,该输入作为json字符串传递给作业。管道然后使用隔离器对此进行解析,然后选择重要信息。然后,它将使用该信息与不同的作业参数并行运行1

  • 下面是我简单的jenkins pipeline groovy脚本,它将用这两个阶段和我们想要构建的作业创建一个管道,我希望在job configuration下的脚本中每次都更新用于构建和代码分析的作业名,方法是从用户界面中获取数据,用户将使用Eclipse提供构建作业名和代码分析作业名- jenkinsfile脚本:-

  • 问题内容: 我有一个jenkins管道,该管道可以构建Java工件,将其复制到目录中,然后尝试执行外部脚本。 我在管道脚本中使用此语法来执行外部脚本 该脚本只是一个简单的Docker构建脚本,但是由于以下异常,构建将失败: 由于脚本不会创建任何目录,因此该错误令人困惑。它只是构建一个docker映像,并将新构建的java工件放置在该映像中。 如果我在jenkins中创建另一个作业,该作业执行外部脚

  • 问题内容: 我们有几个Java项目。每个项目都有自己的交付管道。 所有管道都具有以下共同的步骤(简化): 建立项目 发布项目 部署到测试环境 部署到生产环境 项目管道仅在项目特定的属性(例如服务名称或测试和生产环境的IP地址)上有所不同。 问题是:我们如何避免所有项目都有共同之处?Jenkins的“管道作为代码”是否提供类似管道模板的内容? 我可以想象一个模板将在我们的项目管道中节省很多冗余代码/

  • 问题内容: 这是我要执行的Jenkins管道。我正在关注本教程: 但是作业失败,并显示以下消息。 有人可以帮我解决为什么失败了。 问题答案: 您需要在阶段声明之后添加一个step块。

  • 问题内容: 我已经使用Jenkins为我的node js应用程序创建了CI管道。我的管道包括诸如构建,单元测试,集成测试,代码分析等工作。我知道默认情况下,即使一个测试用例失败,构建也会失败。 问题答案: 您的单元测试脚本将需要处理数学和逻辑,以确定失败的测试百分比足以使整个工作失败。然后,您的单元测试脚本可以返回通过(零)或失败(其他任何结果),詹金斯将相应地标记构建。