詹金斯未能找到Cygwin

时间:2015-01-19 10:41:36

标签: shell jenkins cygwin

我想在带有Cygwin的Windows上使用Jenkins运行shell脚本,但是我收到此错误消息。我的shell程序路径设置为:C:\ cygwin64 \ bin \ bash.exe。我的shell命令是这样的:npm install ./script/test ./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

我现在有点困难,我该怎么办?

由于

3 个答案:

答案 0 :(得分:0)

您可以在没有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"
            }
        }
    }
}
}

我希望这对你有所帮助。 (或者你可以停止接受教育)。

答案 1 :(得分:0)

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

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

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

答案 2 :(得分:0)

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

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目录。在我的情况下,我已经有了#34; SOFTWARE \ Cygwin \ setup \ rootdir只有它似乎无法找到它。我担心有一些问题,它提前退出循环或不正确检查SOFTWARE目录。使用上面发布的解决方案是一个令人不快的工作。