The latest release of the Ruby plugin I develop for Atlassian Bamboo now includes some new configuration options for Bundler along with a number of other additions and improvements. In this post I want to focus on the new options available in the Bundler task, and illustrate how they are used to make Ruby builds simpler.
In the past with my plugin the administrator of the CI server had two options when managing the gems associated with a build:
- Install all the gems required by the project prior to performing a build
- Permit bundler to write to the local ruby installations gem directory
In my view neither of these options is ideal, so I decided I would do some research into staging gems within the working copy of a build. The aim here was to build a ruby project without tainting the local ruby installation, which is one of the key objectives of CI. After some reading I discovered that Bundler could help stage my gems, therefore saving me from doing so.
To take advantage of this feature in Bundler the user was required to pass a couple of switches to install command and then run Bundler’s exec command for all subsequent ruby executions.
To illustrate this using the Bamboo Ruby plugin I will run through configuring a build with a simple rails project.
Firstly we need a ruby, which I install using RVM, you could just use the system provided one if your on OSX.
$ rvm install 1.9.3
Then use this install.
$ rvm use 1.9.3
Now the only gem you need to install is bundler.
$ gem install bundler
Now within Bamboo install the Bamboo Ruby Plugin via the Universal Plugin Manager.
Now go to Server Capabilities in Administration section, and click the Detect Server Capabilities button, this should find your ruby installation as seen below.
Next setup a project and a release plan.
Then within your build Job add the Bundler Task, configuring the path option to vendor/bundle and ticking the binstubs option.
Next add a Rake task to run your database migrations.
Next we want to run the tests in our project, in my case I am using RSpec2 so I use the spec rake task.
As I like to see my test outputs in the CI server I have enabled xml output with my RSpec configuration file and added the rspec_junit_formatter gem to my Gemfile. This produces a JUnit XML report file named rspec.xml which Bamboo parses into test results report.
Now you should enable your build and run it, all going well you should have green, otherwise have a look at the build log and see what the issue was.
So that wraps up my demonstration of Bamboo Ruby Plugin using the awesome bundler gem to enable simple ruby build environments.
comments powered by Disqus