Install (copy & paste):
curl -sL raw.github.com/gist/1676577/travis.rb > ~/bin/travis \
&& chmod +x ~/bin/travis
gem install hub | tail -2
ruby -e 'require "json"' 2>/dev/null || gem install json
You're in a project's directory. Is the current branch green on Travis CI? Let's find out:
$ travis
origin/master built OK.
To check a branch other than current:
$ travis feature
origin/feature built OK.
The travis
command will exit with a non-zero status if the latest build has failed or is still running. This enables you to chain the command like this:
$ travis && rake release
Now if the build has failed, rake release
will never happen and this gives you the chance to fix your library before releasing the gem.
The travis-client gem also provides a command line interface to Travis CI, but I like your interface much better. I'd be interested in taking inspiration from your gist, and making the gem's
travis
binary more script-friendly.Also, if you're interested, I've written a blog post about displaying a project's Travis CI status in your shell prompt.