Skip to content

Integrating rubocop with Jenkins

B. Besmer edited this page Feb 22, 2018 · 2 revisions

Steps to integrate rubocop (static ruby code analyzer) with Jenkins:

Make sure rubocop and rubocop-checkstyle_formatter gems are part of your bundle (preferrably in a development group)

group :development do
  gem 'rubocop'
  gem 'rubocop-checkstyle_formatter', require: false
end

In Jenkins, install the following plugins:
Checkstyle
HTML Publisher

Add a new Execute Shell build step to your Jenkins project, with these contents:

bundle exec rubocop \
--require rubocop/formatter/checkstyle_formatter \
--format RuboCop::Formatter::CheckstyleFormatter -o reports/xml/checkstyle-result.xml \
--format html -o reports/html/index.html || true

Add a new post-build action Publish Checkstyle Results and set this as the results location:

**/reports/xml/checkstyle-result.xml

Add a new post-build action Publish HTML Reports and set this as the HTML directory:

reports/html/  

Next Jenkins job execution should include both reporters on the left sidebar:
Jenkins HTML and Checkstyle reporters