Stack Builders, the Ruby on Rails consultancy that I started, runs all of their projects under Continuous Integration (CI). While we’ve tried a bunch of different Continuous Integration servers and services, we’ve settled on Jenkins. Just a few moments ago, I released the source code that we’re using to run our builds under Jenkins, so I wanted to share some of my thoughts behind writing Railblazer.
For a long time, I set up Rails builds under Jenkins by:
- Creating a database.yml for each project on the build server and
- setting up a script on the server for each project that copies the database.yml into Jenkins’ workspace
I realized after doing this for several months that each database.yml was essentially the same on any given machine, but that the database.sample.yml so often included with the source of Rails projects is usually not the correct match for local configuration. Generally speaking, database configuration is a machine specific, rather than a project specific thing, which makes the practice of providing a database.yml not really that useful.
I decided to see how far I could get towards writing something that auto-detects the database adapter necessary for a Rails application and generates a correct database.yml, based on adapter auto-detection and a local template. This would be the only missing piece to basically have a Rails app configure itself to run tests under Jenkins – as long as you follow best-practices and use RVM and bundler (by creating a Gemfile), it should be straight-forward to write a program to automatically generate a database.yml based on a local template file.
After setting up a new Jenkins server, and adding the first half-dozen project builds for current client projects, it seems that the tools that I have written and released as ‘railblazer’ really does help to configure applications and run builds with minimal intervention. It’s also potentially useful as a tool on a local workstation to generate database.yml files for apps by auto-detection and template rendering rather than by copying and modifying the database.sample.yml provided by others.
I hope it’s as useful for you as it has been for us at Stack Builders! If you have a chance, check it out and let me know what you think. The source code is available at github, and the gem can be installed with ‘gem install railblazer’.