gpt4 book ai didi

linux - 在 Jenkins build Chef 时获得 "Cannot run program "bash""

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:15:46 26 4
gpt4 key购买 nike

我已经在 jenkins 中安装了 chef-plugin 并进行了以下配置:在远程主机上运行 Chef 客户端:

enabled: checked
ssh host: "remote host"
ssh login: root
chef_json template: "{
"run-list" :[
"recipe[test]"
]
}"

color output: checked

出现以下错误:

Started by user swetha sreeramoju
Building in workspace C:\.jenkins\workspace\chef-sample
[2015-05-27 19:06:44 +0530] INFO: [34m[47mrendering ERB template[0m[0m
[2015-05-27 19:06:44 +0530] INFO: [34m[47mparsing JSON string[0m[0m
[2015-05-27 19:06:44 +0530] INFO: [34m[47msaving JSON to file[0m[0m
[2015-05-27 19:06:44 +0530] INFO: [2m[1m[34m[47m[4mchef json url[0m[0m[0m[0m[0m[34m[47m : http://localhost:8080/jenkins//job/chef-sample/ws/chef.json[0m[0m
[2015-05-27 19:06:44 +0530] INFO: [2m[1m[34m[47m[4mhost[0m[0m[0m[0m[0m[34m[47m : 10.0.12.209[0m[0m
$ bash -c "ssh root@10.0.12.209 sudo chef-client -l info -j http://localhost:8080/jenkins//job/chef-sample/ws/chef.json "
ERROR: Cannot run program "bash": CreateProcess error=2, The system cannot find the file specified (Java::JavaIo::IOException)
java.lang.ProcessBuilder.start(Unknown Source)
hudson.Proc$LocalProc.<init>(Proc.java:244)
hudson.Proc$LocalProc.<init>(Proc.java:216)
hudson.Launcher$LocalLauncher.launch(Launcher.java:816)
hudson.Launcher$ProcStarter.start(Launcher.java:382)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:440)
org.jruby.javasupport.JavaMethod.invokeDirect(JavaMethod.java:304)
org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:52)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:134)
org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:64)
org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:112)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:126)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:163)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:70)
org.jruby.ast.FCallSpecialArgNode.interpret(FCallSpecialArgNode.java:45)
org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:64)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:112)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:126)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:163)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:70)
org.jruby.ast.CallManyArgsNode.interpret(CallManyArgsNode.java:59)
org.jruby.ast.CallOneArgFixnumNode.interpret(CallOneArgFixnumNode.java:59)
org.jruby.ast.IfNode.interpret(IfNode.java:110)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.ast.IfNode.interpret(IfNode.java:116)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:268)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:220)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:236)
org.jruby.ast.CallThreeArgNode.interpret(CallThreeArgNode.java:61)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:209)
org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:160)
org.jruby.runtime.Interpreted19Block.yieldSpecific(Interpreted19Block.java:133)
org.jruby.runtime.Block.yieldSpecific(Block.java:99)
org.jruby.ast.ZYieldNode.interpret(ZYieldNode.java:25)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.ast.RescueNode.executeBody(RescueNode.java:224)
org.jruby.ast.RescueNode.interpret(RescueNode.java:119)
org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:204)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:196)
org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:177)
org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:188)
org.jruby.ast.FCallOneArgBlockNode.interpret(FCallOneArgBlockNode.java:34)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:112)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:126)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:163)
org.jruby.javasupport.proxy.JavaProxyConstructor$2.invoke(JavaProxyConstructor.java:224)
org.jruby.proxy.hudson.tasks.Builder$Proxy2.perform(Unknown Source)
hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:764)
hudson.model.Build$BuildExecution.build(Build.java:205)
hudson.model.Build$BuildExecution.doRun(Build.java:162)
hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
hudson.model.Run.execute(Run.java:1744)
hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
hudson.model.ResourceController.execute(ResourceController.java:98)
hudson.model.Executor.run(Executor.java:374)

Build step 'Run chef client on remote host' marked build as failure
Finished: FAILURE

Chef 客户端和服务器运行在 Linux 机器上,jenkins 在 Windows7 中配置。

最佳答案

问题似乎有点广泛,如此处所述SSH+slaves+and+Cygwin :

This is because Jenkins is trying to call Windows API and execute "/bin/bash" without going through Cygwin path translation. Windows interprets /bin/bash as c:\bin\bash.exe, and unless that path exists, it will fail.

一个快速的解决方案是从 linux 节点传递。

另一种快速的可能性是在 Chef-client linux 机器之外创建一个按需 Jenkins 节点(点击几下)并在那里运行正确的 shell 行(尽管它可能更像是 hack) :

chef-client -l info -j http://localhost:8080/jenkins//job/chef-sample/ws/chef.json 

关于linux - 在 Jenkins build Chef 时获得 "Cannot run program "bash"",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30484592/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com