Jenkins Test Coverage

Please read below for Jenkins-specific considerations when integration with Code Climate's test reporter.

If you're using the GHPRB Plugin in order to report your build status to GitHub, please read the section below on configuring that plugin properly for use with Code Climate.

Jenkins CI Builds

When Jenkins creates a build, it can sometimes run the build on a detached HEAD, causing the commit SHA to be different from the SHA of your branch. This will cause issues when reporting test coverage to Code Climate. In order to have the original commit SHA persist through the build process, use the following code snippet in your after-build step:

echo $GIT_COMMIT # only needed for debugging 
GIT_COMMIT=$(git log | grep -m1 -oE '[^ ]+$')
echo $GIT_COMMIT # only needed for debugging 

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

This will ensure that the proper git commit SHA will be used and reported to Code Climate.

Use with GHPRB Plugin

When using the ghprb-plugin to build out pull requests, the plugin changes the raw SHA during the build, and the modified SHA will then be reported back to Code Climate. In order for test coverage statuses to show in GitHub, we'll need to report the initial SHA variable, not the modified one. To start, in Branch Specifier, instead of the default */master, enter the following:

${ghprbActualCommit} if you want to use the head of the pull request branch (e.g. refs/pull/4/head)


After proceeding with that step, your PR's should report as expected not only in the dashboard, but also the GitHub PR's.