As Google remained relatively quiet on the topic of sending cobertura code coverage reports from CircleCI to Codecov, I decided to give it a try. Surprisingly, the integration was much easier than expected, thanks to an amazing bash script provided by Codecov!

CircleCI, Codecov and Cobertura are very good tools that integrate well together. As of writing the only missing piece is the documentation.

In order to generate a Cobertura code coverage report for your Java project, you simply need to add the following plugin to your pom.xml file.


Then, the maven goal cobertura:cobertura generates an xml and an html report for your project, both of which are located in the target/site/cobertura directory. The html format is pretty handful, however what about sending the xml report to Codecov?

CircleCI can easily be configured to perform this operation after each build. The following .circleci/config.yml file illustrates how this can be done.

version: 2
      - image: circleci/openjdk:8u181-jdk
    working_directory: ~/repo
      MAVEN_OPTS: -Xmx3200m
      - checkout
      - restore_cache:
            - v1-dependencies-
            - v1-dependencies-
      - run: mvn install
      - run: mvn test
      - run: "mvn cobertura:cobertura"
      - run: "bash <(curl -s"
      - save_cache:
            - ~/.m2
          key: v1-dependencies-

Codecov did quite an amazing job with their bash script that supports an impressive list of reports and formats, among which Cobertura. That’s it, tokens are not needed for public projects and a nice report will appear on your Codecov dashboard.