Answers: <p>The issue has been resolved.
  This is for nodejs</p>
  
  <p>Need to install necessary dependencies either using yarn or npm.
  Once done, run </p>
  
  <pre><code>nyc --reporter=lcov yarn unit unit
  $ ./cc-test-reporter after-build -t lcov --exit-code $?
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2019-12-20T10:10:28.487Z
Answers: 2019-12-20T10:10:28.487Z
Answers: Manish_
Body: <p>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.</p>
  
  <p>I tried to integrate code climate with Jenkins so that once the tests are successful, I can simply move on with other Jenkins Job.</p>
  
  <p>I consulted the documentation itself, and as per documentation there are things like but there is not much explanation about it.</p>
  
  <p><code>./cc-test-reporter after-build -t simplecov --exit-code $? || echo  “Skipping Code Climate coverage upload”</code></p>
  
  <p>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.</p>
  
  <pre><code>#!/bin/bash
  echo "---------------------------------------"
  echo "| Downloading Code Climate "
  curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 &gt;&gt; ./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.
  </code></pre>
  
  <p>Once I execute this, I get the following output.</p>
  
  <pre><code>---------------------------------------
  | 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
  </code></pre>
  
  <p>Why am I not getting any code coverage or things like that in the console. How do I properly integrate it in Jenkins.</p>
  
  <p><strong><code>UPDATE</code></strong>
  I have successfully created the job without issue.
  Now the problem I am facing is </p>
  
  <pre><code>$ ./cc-test-reporter format-coverage -t lcov coverage/lcov.info -d -o codeclimate.json
  DEBU[0000] coverage path coverage/lcov.info             
  DEBU[0000] using formatter lcov                         
  DEBU[0000] checking search path coverage/lcov.info for lcov formatter 
  DEBU[0000] couldn't load branch from ENV, trying git... 
  DEBU[0000] couldn't load commit sha from ENV, trying git... 
  DEBU[0000] couldn't load committed at from ENV, trying git... 
  Error: could not find coverage info for source files
  
  user@host:app$ pwd
  app
  user@host:app$ ll
  coverage
  user@host:app$ ll coverage
  lcov-report
  lcvo.info
  </code></pre>
  
Tags: <jenkins><code-coverage>
Title: Using Code Climate for Test Coverage alongside Jenkins
UserDisplayName: Manish_
ThreadText: # Using Code Climate for Test Coverage alongside Jenkins
  
  (Asked by: username_0 on 2019-12-13)
  
  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.
  Now the problem I am facing is
  
  ```
  $ ./cc-test-reporter format-coverage -t lcov coverage/lcov.info -d -o codeclimate.json
  DEBU[0000] coverage path coverage/lcov.info             
  DEBU[0000] using formatter lcov                         
  DEBU[0000] checking search path coverage/lcov.info for lcov formatter 
  DEBU[0000] couldn't load branch from ENV, trying git... 
  DEBU[0000] couldn't load commit sha from ENV, trying git... 
  DEBU[0000] couldn't load committed at from ENV, trying git... 
  Error: could not find coverage info for source files
  
  user@host:app$ pwd
  app
  user@host:app$ ll
  coverage
  user@host:app$ ll coverage
  lcov-report
  lcvo.info
  
  ```
  
  **Tags:** jenkins, code-coverage
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-12-20. Score: 1
  
  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 $?
  
  ```
  
  
  ---
  
  