Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup code climate test coverage for jenkins CI

I am using code climate for code quality and test coverage. I have added the gem and code in spec_helper.rb to start the coverage. In the next step code as per the documentation: When you run your tests on CI, set the CODECLIMATE_REPO_TOKEN environment variable: $CODECLIMATE_REPO_TOKEN=******************** bundle exec rake

I tried to set the above line in the execute shell commands of jenkins. Also tried to set the environment variables CODECLIMATE_REPO_TOKEN in the Manage jenkins -> Configure System settings. But that doesn't work. I couldn't find any documentation to setup test coverage with jenkins. Any help would be appreciable.

As per the code-climate documentation

Add the codeclimate-test-reporter gem to your Gemfile:

gem "codeclimate-test-reporter", group: :test, require: nil

Start the test reporter on the very first line of spec_helper.rb or test_helper.rb:

require "codeclimate-test-reporter" CodeClimate::TestReporter.start

When you run your tests on CI, set the CODECLIMATE_REPO_TOKEN environment variable:

$ CODECLIMATE_REPO_TOKEN=**************************** bundle exec rake

(Note: This token is specific to this repo on Code Climate.)

(Note: **As an alternative to the above, you may prefer to define this token as environment variable within your CI's user interface or configuration file**.) 

Its written here that the token environment variable is to be defined within your CI server. That is what my question is where to define it in jenkins. I tried defining the global environment variable in jenkins under "Manage jenkins"->"System configuration". But it didn't work.

enter image description here

like image 307
Ajeet Khan Avatar asked Sep 16 '15 12:09

Ajeet Khan


People also ask

What is code climate diff coverage?

Code Climate allows users to enforce test coverage via our Github Pull Request Integration. The Enforce Diff Coverage option requires all new code in a Pull Request to meet a configurable minimum threshold of test coverage percentage. The default threshold is 50%.


1 Answers

If your question is how to set an environment variable in Jenkins, you may look e.g. here: How to set environment variables in Jenkins?

like image 174
The Ancient Avatar answered Oct 16 '22 18:10

The Ancient