【问题标题】:Jenkins failed to locate Cygwin詹金斯未能找到 Cygwin
【发布时间】:2015-01-19 10:41:36
【问题描述】:

我想在带有 Cygwin 的 Windows 上使用 Jenkins 运行 shell 脚本,但我收到此错误消息。我将我的 shell 程序路径设置为:C:\cygwin64\bin\bash.exe。我的 shell 命令是这样的: npm install ./脚本/测试 ./script/deploy.

这是我的 github 存储库:https://github.com/y0u-s/test

hudson.util.IOException2: Failed to locate Cygwin installation. Is Cygwin installed?
    at hudson.plugins.cygpath.CygpathLauncherDecorator$GetCygpathTask.getCygwinRoot(CygpathLauncherDecorator.java:138)
    at hudson.plugins.cygpath.CygpathLauncherDecorator$GetCygpathTask.call(CygpathLauncherDecorator.java:142)
    at hudson.plugins.cygpath.CygpathLauncherDecorator$GetCygpathTask.call(CygpathLauncherDecorator.java:112)
    at hudson.remoting.LocalChannel.call(LocalChannel.java:45)
    at hudson.plugins.cygpath.CygpathLauncherDecorator$1.getCygpathExe(CygpathLauncherDecorator.java:104)
    at hudson.plugins.cygpath.CygpathLauncherDecorator$1.cygpath(CygpathLauncherDecorator.java:86)
    at hudson.plugins.cygpath.CygpathLauncherDecorator$1.launch(CygpathLauncherDecorator.java:65)
    at hudson.Launcher$ProcStarter.start(Launcher.java:381)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:97)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
    at hudson.model.Build$BuildExecution.build(Build.java:199)
    at hudson.model.Build$BuildExecution.doRun(Build.java:160)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:533)
    at hudson.model.Run.execute(Run.java:1759)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:89)
    at hudson.model.Executor.run(Executor.java:240)
Caused by: hudson.util.jna.JnaException: Win32 error: 2 - The system cannot find the file specified
    at hudson.util.jna.RegistryKey.check(RegistryKey.java:124)
    at hudson.util.jna.RegistryKey.open(RegistryKey.java:223)
    at hudson.util.jna.RegistryKey.openReadonly(RegistryKey.java:218)
    at hudson.plugins.cygpath.CygpathLauncherDecorator$GetCygpathTask.getCygwinRoot(CygpathLauncherDecorator.java:127)
    ... 18 more

我现在有点卡住了,我该怎么办?

谢谢

【问题讨论】:

    标签: shell jenkins cygwin


    【解决方案1】:

    好的,我将在几个地方发布这个解决方案,因为这对我有用,而且这个问题出现在几个问题中。不幸的是,该解决方案需要进行一些注册表编辑。

    TLDR 解决方案:

    - Open regedit.
    - Go to HKEY_LOCAL_MACHINE - SOFTWARE - Wow6432Node
    - Right click on Wow6432Node New->Key name it Cygwin
    - Right click on Cygwin New->Key name it setup
    - Right click on setup New->String Value name it rootdir
    - Right click on rootdir Modify set it to your cygwin folder mine was "C:\cygwin64"
    

    推理

    https://github.com/jenkinsci/cygpath-plugin/blob/master/src/main/java/hudson/plugins/cygpath/CygpathLauncherDecorator.java

    是 Jenkins 如何找到 Cygwin 的代码。第 115 行是 for 循环的开始,它最初在 SOFTWARE\Wow6432Node 中查找,然后在 SOFTWARE 中查找 Cygwin 目录。在我的情况下,我已经有了“SOFTWARE\Cygwin\setup\rootdir 只是它似乎无法找到它。我冒险存在一些问题,它会提前退出循环或没有正确检查 SOFTWARE 目录。使用解决方案上面发布的是解决此问题的令人不快的工作。

    【讨论】:

      【解决方案2】:

      使用 (C:\cygwin64\bin\bash) 在您的 Jenkins Shell 可执行文件 变量中设置。

      系统变量中设置CYGWIN变量(CYGWIN=nodosfilewarning)

      确保将 (#!/bin/bash) 放在 shell 命令的开头

      【讨论】:

      • 你是怎么做所有这些事情的?其中一些是在 Windows 服务器上完成的吗?其他在詹金斯界面内完成吗?什么屏幕?
      【解决方案3】:

      您可以在没有 Cygwin 的情况下运行 shell 脚本。只需将此代码添加到您的 build.xml

      apply plugin: 'maven'
      
      group = "de.myapp"
      version = '2.2.0'
      
      android {
          ...
      }
      
      uploadArchives {
      repositories {
          mavenDeployer {
              maven {
                  name "snapshot_repo"
                  url "http://192.168.178.85:8081/nexus/content/repositories/myapp_snapshots"
      
                  credentials {
                      username  "admin"
                      password  "admin123"
                  }
              }
          }
      }
      }
      

      我希望这对你有所帮助。

      【讨论】:

        猜你喜欢
        • 2020-10-16
        • 2020-09-29
        • 2012-09-30
        • 2014-07-24
        • 2018-02-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多