For the latest updates and improvements, see the latest Cloud documentation instead.
Getting started¶
Authentication¶
- Find and copy a Project API Token. You can find the token within a repository Settings → Integrations → Project API.
- Set the Project API Token in your terminal, replacing
%Project_Token%
with your own:
export CODACY_PROJECT_TOKEN=%Project_Token%
Warning
You should keep your API token well protected, as it grants owner permissions to your projects.
Hint
If you'd like to automate this process for multiple repositories you can authenticate using an Account API Token.
Note
To upload coverage to a self-hosted installation of Codacy you need to set your installation URL:
export CODACY_API_BASE_URL=<Codacy_instance_URL>:16006
Or use the flag: --codacy-api-base-url <Codacy_instance_URL>:16006
.
Running Codacy Coverage Reporter¶
The easiest way to get starting is by using the self-contained script that downloads and runs the reporter:
bash <(curl -Ls https://coverage.codacy.com/get.sh)
Choose a specific version¶
The script uses by default the latest version.
If you want to specify a coverage reporter version, use CODACY_REPORTER_VERSION
environment variable.
You can find all versions in the Releases tab.
Manual Installation¶
Using CircleCI? Check out the codacy/coverage-reporter orb.
Using GitHub Actions? Check out the codacy/coverage-coverage-reporter action.
If the automated script does not cover your use case, check the manual installation methods.
Supported formats¶
The following table contains the formats supported and which coverage tools generate them:
Language | Coverage tools (examples) | Formats | Filename |
---|---|---|---|
Java | JaCoCo Cobertura |
JaCoCo Cobertura |
jacoco*.xml cobertura.xml |
Scala | sbt-jacoco scoverage |
JaCoCo Cobertura |
jacoco*.xml cobertura.xml |
Javascript | Istanbul Poncho Mocha + Blanket.js |
LCOV | lcov.info, lcov.dat, *.lcov |
Python | Coverage.py | Cobertura | cobertura.xml |
PHP | PHPUnit | PHPUnit XML (version <= 4) Clover |
coverage-xml/index.xml clover.xml |
Ruby | SimpleCov | Cobertura LCOV |
cobertura.xml lcov.info, lcov.dat, *.lcov |
C# | OpenCover DotCover CLI |
OpenCover DotCover-DetailedXML |
opencover.xml dotcover.xml |
Swift/Objective-C | XCode Coverage | Check here information about reports for this language |
The reporter assumes the coverage reports filename follow the name convention. Otherwise, you must define the report's location with the flag -r
.
Note
If your coverage reports are in a different format you can use a format converter, such as ReportGenerator, to generate a supported format.
Unsuported Languages¶
If your language is not in the list of supported languages, you can still send coverage to Codacy. You can do it by providing the correct --language
name and then add the --force-language
flag.
Commit SHA hash detection¶
Codacy automatically detects a commit SHA hash from CI workflows, the git repository or command line arguments. See all supported environments.
Multiple coverage reports for the same language¶
You can upload multiple reports if your test suite is split in different modules or ran in parallel. See how to uploasd multiple coverage reports.
Other commands¶
For a complete list of commands and options: --help
Share your feedback 📢
Did this page help you?
Thanks for the feedback! Is there anything else you'd like to tell us about this page?
255 characters left
We're sorry to hear that. Please let us know what we can improve:
255 characters left
Alternatively, you can create a more detailed issue on our GitHub repository.
Thanks for helping improve the Codacy documentation.
If you have a question or need help please contact support@codacy.com.