tags:

views:

99

answers:

2

I'm using Ruby and Rake to do our builds at the moment for .Net projects.

I call a few commandline tools, such as NCover to check the coverage is high enough. When NCover returns and exit (fail) code though, Rake exits immediately stops.

Is there a hook, like on_exit, that I can use. I basically want to output "Build FAILED" in nice red writing, and if possible the step it failed on, and even better a message as to why. Just so it's a little clearer to the devs.

There is something similar in NAnt, and it's quite handy. Wondering if Rake/Ruby had anything similar.

Anyone had any experience with this sort of thing?

Cheers.

+1  A: 

Maybe you can check for the error returned by the tool like this:

sh %{NCover file} do |ok, res|
  if ! ok
    raise "Build FAILED in NCover"
  end
end
Vincent
+1  A: 

Ruby has at_exit. You can use it like this:

at_exit do
   puts "this gets printed before the script finishes"
end
Geo
Ah damn it, should have just tried it. I use that in Cucumber, wasn't sure if it was specific to that though. Cheers.
Bealer
No problem, glad to help!
Geo