Capturing Rake return codes

Eric PughMay 8, 2007

Based on Martin Fowler’s whole pitch on declarative versus imperative builds, I converted a basic Ruby script into a Rake based script. However, the one gotcha I hit was that running rake dist, the return code wasn’t returned. Yes, rake would say it failed:

(in E:/irocket/continuum/working-directory/6)
rake aborted!
I should fail the build
E:/irocket/continuum/working-directory/6/rakefile:310

We are using Continuum, a very simple to set up CI tool, and it requires whatever script it calls to return 0 on success, and > 0 on failure. So even though Rake would say the build failed, it always return 0. It turns out that some people have run into this problem:

I didn’t want to hack up my rake.bat and rake.cmd files, so instead I am calling ruby directly:

ruby -x e:\irocket\ruby\bin\rake.bat dist

Hopefully the next version of Rake will have this resolved! The Continuum project went through this same pain for Ant and Maven scripts, and have posted their fixed batch files.




More blog articles:


Let's do a project together!

We provide tailored search, discovery and analytics solutions using Solr and Elasticsearch. Learn more about our service offerings