失败后继续耙

DrS*_*myD 6 ruby cruisecontrol.net rake nunit

我正在运行rake来自动化我在CCNet内部的构建过程.我用它来启动IIS Express,然后运行Nunit,然后在Nunit完成后关闭服务器.问题是,每次Nunit失败,耙子停止,永远不会到达关闭部分.在Nunit失败后如何继续使用rake,并且仍然告诉CCNet Nunit失败了,构建也是如此?

kit*_*ite 6

你如何从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
Run Code Online (Sandbox Code Playgroud)

关闭服务器后将此引发异常置于有效状态,以便ccnet知道构建失败

    raise "NUnit failed" if nunitSuccessFlag == false
Run Code Online (Sandbox Code Playgroud)

替代方法:使用上面用户knut所述的try catch块,如以下链接所示: Rake Task:错误处理(在ensure块中关闭服务器)


zan*_*edp 5

我用它来rake忽略从命令返回的状态:

sh "the command || true"
Run Code Online (Sandbox Code Playgroud)

true总是没有错误地退出,使sh总是看到成功。