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.

Bealer
  • 864
  • 9
  • 16

2 Answers2

3

Ruby has at_exit. You can use it like this:

at_exit do
   puts "this gets printed before the script finishes"
end
Geo
  • 93,257
  • 117
  • 344
  • 520
  • 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 Oct 15 '09 at 16:12
1

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
  • 4,883
  • 2
  • 25
  • 17