失败后继续耙 [英] Continue Rake after failure

查看:79
本文介绍了失败后继续耙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行rake,以在CCNet中自动执行构建过程。我用它来启动IIS Express,然后运行Nunit,然后在Nunit完成后关闭服务器。问题是,每当Nunit发生故障时,耙子就会停止,并且永远不会进入关闭部分。在Nunit失败后如何继续进行耙,并仍然告诉CCNet Nunit失败了,因此构建也是如此?

I'm running rake to automate my build process inside of CCNet. I use it to start IIS Express, then run Nunit, and then shutdown the server after Nunit has finished. The problem is that every time Nunit fails, the rake stops, and never gets to the shutdown part. How do I continue a rake after Nunit has failed, and still tell CCNet that Nunit has failed, and thus so has the build?

推荐答案

如何从rake运行NUnit?

How do you run NUnit from rake? are you using "sh"?

这是您使用 sh执行shell命令并拦截结果的方式。

This is how you use "sh" to execute shell command, and intercept the result.

我只是用空块忽略任何结果(失败或成功)

I just use empty block to ignore any result(failed or success)

            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

设置true或false服务器,因此ccnet知道构建失败

put this raise exception after shutting down the server so ccnet knows that build failed

    raise "NUnit failed" if nunitSuccessFlag == false

替代:如上面的链接所示,使用上面用户knut所述的try catch块:
Rake任务:错误处理(在确保模块中关闭服务器)

alternative: use try catch block as stated by user knut above as shown in this link: Rake Task: error handling (shut down the server in the ensure block)

这篇关于失败后继续耙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆