Jenkins 无法找到 Cygwin

Jenkins 无法找到 Cygwin

我的詹金斯工作失败,因为它给出了以下错误消息:

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

我在 Windows 上运行 Jenkins 并想运行此 github repo 中的脚本:https://github.com/y0u-s/test

我将 Jenkins shell 程序路径设置为:C:\cygwin64\bin\bash

我现在陷入了困境,我该怎么做才能解决这个问题?

答案1

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

TLDR 解决方案:

- Make sure cygwin is installed
- 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 目录。使用上面发布的解决方案是解决这个问题的一个不愉快的解决方法。

相关内容