Thursday, June 19, 2014

Jenkins Plugins - Claim, Brakeman, Ruby Metrics

Claim

This is now installed on Jenkins & will let people claim broken builds - ie tell the world that you are going to fix it and how long you think it will take.
It needs to be enabled on a project by project basis, you do this when configuring your project by adding the 'Allow broken build claiming' post build action.

Brakeman

This is now installed on Jenkins & will display the output of the Brakeman static analysis gem.
To configure:
1 Add the brakeman gem to your Gemfile, eg
group :test do
  ...
  gem "brakeman"
  ...
end
2 Add a line at the end of your Jenkins execute shell task to run brakeman, eg
bash -l -c 'brakeman -o brakeman-output.tabs'
3 Enable displaying the output by adding the 'Publish brakeman warnings' post build action to your project Jenkins configuration & setting the output file to point at the file you specified in step 2.

Ruby Metrics

The Jenkins Ruby Metrics plugin will display the output of rcov unit test coverage.
The easiest way we found to set this up:
1. Add simplecov & simplecov-rcov to your Gemfile, eg
group :test do
  ...
  gem "simplecov", ">=0.3.8", :require => false
  gem 'simplecov-rcov'
  ...
end
2. Create a file called .simplecov in the root directory of your project
require 'simplecov-rcov'
class SimpleCov::Formatter::MergedFormatter
  def format(result)
    SimpleCov::Formatter::HTMLFormatter.new.format(result)
    SimpleCov::Formatter::RcovFormatter.new.format(result)
  end
end
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
SimpleCov.start 'rails' do
  # any custom configs like groups and filters can be here at a central place
  add_filter "/vendor/"
end
3. Update spec/spec_helper & features/support/env.rb to require simplecov  ... add this after require 'rubygems' but before all else
require 'simplecov'
4. In Jenkins, enable displaying the output by adding the 'Publish rcov report' post build action in your project Jenkins configuration and pointing it at the coverage/rcov directory
5. See beautiful reports in Jenkins, and also locally when you've run the tests
6. Improve your tests!
.

No comments:

Post a Comment