MY Scribbling...

AWS Community Hero Masanori YAMAGUCHI の 雑なメモ

serverspecで実行結果の出力をjenkinsに読ませる

ci_reporterだけだとエラーになる。 ci_reporter_rspecをインストールした実行出来た。

ci_reporter_rspecのインストール

ci-reporter/ci_reporter_rspec · GitHub

Gemfileに追記して

gem 'ci_reporter_rspec'

bundleを実行

bundle

ServerspecのRakefileに以下を追記

require 'ci/reporter/rake/rspec'

実行結果

# bundle exec rake ci:setup:rspec spec --trace
** Invoke ci:setup:rspec (first_time)
** Invoke ci:setup:spec_report_cleanup (first_time)
** Execute ci:setup:spec_report_cleanup
rm -rf spec/reports
** Execute ci:setup:rspec
** Invoke spec (first_time)
** Execute spec
/usr/local/bin/ruby -S rspec spec/jenkins-test/httpd_spec.rb
.

Finished in 0.26314 seconds
1 example, 0 failures
[root@chef-workstation chef-solo]# bundle exec rake ci:setup:rspec spec 
rm -rf spec/reports
/usr/local/bin/ruby -S rspec spec/jenkins-test/httpd_spec.rb
.

Finished in 0.25619 seconds
1 example, 0 failures

出力はこんな感じ

# cat spec/reports/SPEC-Package-httpd-.xml 
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="Package &quot;httpd&quot;" tests="1" time="0.256167582" failures="0" errors="0" skipped="0" timestamp="2014-08-20T11:38:34+09:00">
  <testcase name="Package &quot;httpd&quot; should be installed" time="0.174078009">
  </testcase>
</testsuite>