Capturing Rake return codes

Eric PughMay 8, 2007

Based on Martin Fowlers 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 wasnt returned. Yes, rake would say it failed:

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

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 didnt 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:

We empower great search teams!

We help teams that use Solr and Elasticsearch become more capable through consulting and training.

Services Training