概要
simplecovのカバレッジレポートをJenkinsに表示する
詳細
simplecovのカバレッジレポートをJenkinsに表示します。
サンプル
前提
Ruby 2.0.0-p247
Rails 4.0.0
MiniTest
検証に利用するプロジェクト
sample_todo(私がGitHubに作成した検証用プロジェクト)
https://github.com/tbpgr/sample_todo
Rails設定
・Gemfileに下記を追加
gem 'simplecov', '~> 0.7.1' gem "simplecov-rcov", "~> 0.2.3"
・test/test_helper.rbに追記
require "simplecov" require 'simplecov-rcov' SimpleCov.start "rails" SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
Jenkins設定
・Ruby metrics pluginをインストール
実行手順
・Jenkinsの新規ジョブ作成
・ソースコード管理システム欄でgitを選択
・リポジトリURLに「https://github.com/tbpgr/sample_todo.git」を入力
・リポジトリブラウザはgithubwebを選択して
URLに「https://github.com/tbpgr/sample_todo」を入力
・ビルドにシェルの実行を追加
bundle install --path=vendor/bundle bundle exec rake db:create bundle exec rake db:migrate RAILS_ENV=test bundle exec rake test
・ビルド後の処理にPublish Rcov Reportを追加
Rcov report directoryに「coverage/rcov」を設定(デフォルトの出力から変更していない場合)
Total coverage、Code coverage欄でカバレッジ率に対するアイコン表示を3種類設定できます。