1
請幫我從ruby腳本調用.bat文件。我嘗試了以下。我的test.rb文件如下:從ruby腳本調用.bat文件
batch "run-script" do
cwd 'D:\\jenkins\jobs\HybrisJob\workspace'
code <<-EOH
`hybrisserver.bat`
EOH
action :run
end
但它不工作。
[2015-03-19T14:01:16+05:30] FATAL: Mixlib::ShellOut::ShellCommandFailed: batch[run-script] ((chef-apply cookbook)::(chef-apply recipe) line 1) had an error:
Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
那麼cwd資源不可用於廚師食譜?我試過這個'cwd'D:// jenkins/jobs/HybrisJob/workspace'' system('hybrisserver.bat')並且出錯'FATAL:NoMethodError:'Chef :: Recipe沒有名爲'cwd'的資源或方法'' – javaUser 2015-03-19 09:40:26
cwd是批量資源的一個屬性,用於告訴它從哪裏啓動cmd.exe。沒有cwd資源。看到我的答案,這是您的問題中更正的批量資源。在配方中運行ruby命令不被推薦 – Tensibai 2015-03-19 09:43:45
ThanksTensibai,它的工作! – javaUser 2015-03-19 09:45:44