失败后继续耙
我正在运行rake来自动化我在CCNet内部的构建过程。 我用它来启动IIS Express,然后运行Nunit,然后在Nunit完成后关闭服务器。 问题是每次Nunit失败,耙子停止,永远不会到达关闭部分。 在Nunit失败后如何继续使用rake,并且仍然告诉CCNet Nunit失败了,构建也是如此?
你如何从rake运行NUnit? 你在用“sh”吗?
这是你使用“sh”执行shell命令并拦截结果的方法。
我只是使用空块来忽略任何结果(失败或成功)
sh "your shell command" do |ok,res| #empty block to ignore any failed or success status #in your case set failed flag based on ok parameter nunitSuccessFlag=false #hardcoded for sample; must set true or false based on ok parameter end
关闭服务器后将此引发exception置于有效状态,以便ccnet知道构建失败
raise "NUnit failed" if nunitSuccessFlag == false
替代方法:使用上面用户knut所述的try catch块,如以下链接所示: Rake Task:error handling (在ensure块中关闭服务器)
我使用它来使rake
忽略从命令返回的状态:
sh "the command || true"
true
总是在没有错误的情况下退出,这使得sh
总能看到成功。