HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Using Code Climate for Test Coverage alongside Jenkins

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
climatealongsidejenkinstestforusingcodecoverage

Problem

My company is currently trying to implement Code Climate for test coverage. However, I do not have much idea about it and new to using code climate.

I tried to integrate code climate with Jenkins so that once the tests are successful, I can simply move on with other Jenkins Job.

I consulted the documentation itself, and as per documentation there are things like but there is not much explanation about it.

./cc-test-reporter after-build -t simplecov --exit-code $? || echo “Skipping Code Climate coverage upload”

I executed this, but returned there is no such file simplecov. I later found that the -t flag is used to provide the file which will be used for coverage. Below is my Jenkins job.

#!/bin/bash
echo "---------------------------------------"
echo "| Downloading Code Climate "
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 >> ./cc-test-reporter
chmod +x ./cc-test-reporter
echo "| Download Complete "
echo "---------------------------------------"

CODECLIMATE_REPO_TOKEN=${CODECLIMATE_REPO_TOKEN}
echo "Running tests"
./cc-test-reporter before-build.


Once I execute this, I get the following output.

---------------------------------------
| Downloading Code Climate 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   178  100   178    0     0    933      0 --:--:-- --:--:-- --:--:--   936

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 12.1M  100 12.1M    0     0  10.0M      0  0:00:01  0:00:01 --:--:-- 15.8M
| Download Complete 
---------------------------------------
Running tests
Finished: SUCCESS


Why am I not getting any code coverage or things like that in the console. How do I properly integrate it in Jenkins.

UPDATE
I have successfully created the job without issue.

Solution

The issue has been resolved.
This is for nodejs

Need to install necessary dependencies either using yarn or npm.
Once done, run

nyc --reporter=lcov yarn unit unit
$ ./cc-test-reporter after-build -t lcov --exit-code $?

Code Snippets

nyc --reporter=lcov yarn unit unit
$ ./cc-test-reporter after-build -t lcov --exit-code $?

Context

StackExchange DevOps Q#10099, answer score: 1

Revisions (0)

No revisions yet.