Last active
August 30, 2019 15:29
-
-
Save mrfyda/51cdf48fa0722593db6a to your computer and use it in GitHub Desktop.
sbt-codacy-coverage uploader for Java 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
function coverageFilePath { echo "target/scala-$1/coverage-report/codacy-coverage.json"; } | |
PROJECT_TOKEN=${CODACY_PROJECT_TOKEN} | |
if [ -z "${PROJECT_TOKEN}" ]; then | |
echo "Project token not found." | |
exit 1 | |
fi | |
COMMIT_UUID=`git rev-parse --verify HEAD` | |
if [[ $? != 0 ]]; then | |
echo "Not a valid git repository." | |
exit 1 | |
fi | |
if [ -f `coverageFilePath "2.11"` ]; then | |
COVERAGE_REPORT=`coverageFilePath "2.11"` | |
else | |
if [ -f `coverageFilePath "2.10"` ]; then | |
COVERAGE_REPORT=`coverageFilePath "2.10"` | |
else | |
echo "Coverage report not found." | |
exit 1 | |
fi | |
fi | |
COVERAGE_REPORT_CONTENT=`cat ${COVERAGE_REPORT}` | |
curl -X POST https://api.codacy.com/2.0/coverage/${COMMIT_UUID}/scala -d ${COVERAGE_REPORT_CONTENT} \ | |
--header "Content-Type: application/json" \ | |
--header "project_token: ${PROJECT_TOKEN}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment