Codecov

Code coverage done right.®

Welcome to Codecov Documentation. You'll find comprehensive guides and documentation to help you start working with Codecov as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started

Codecov Bash uploader

Introduction

The Codecov Bash uploader provides a language-agnostic alternative for uploading reports. Its usage is both simple and convenient:

bash <(curl -s https://codecov.io/bash)

The main objectives of the uploader are to:

  • detect the environment
  • gather reports
  • upload them to Codecov

The above command silently requests the latest version of the uploader from Codecov and executes via Bash; all output is directed to stdout.

Upload token

Not Required for some CI Providers

If you have a public project on TravisCI, CircleCI, AppVeyor, or Azure Pipelines an upload token is not required.

A unique upload token is required to identify which project the coverage belongs to. This token is located in the repository settings (/gh/:owner/:repo/settings).

A repository on codecov with no uploaded coverage reports.  Note the upload token.

A repository on codecov with no uploaded coverage reports. Note the upload token.

There are three ways to provide the upload token to the Bash uploader:

Flag

bash <(curl -s https://codecov.io/bash) -t token

Environment variable

export CODECOV_TOKEN="token"
bash <(curl -s https://codecov.io/bash)

File

echo "token" > .cc_token
bash <(curl -s https://codecov.io/bash) -t @.cc_token

CI detection

The bash uploader detects all CI providers through environment variables. This process helps to identify the source of the build and maintain a relationship back to the source of the coverage collection.

Finding reports

Codecov can automatically detect coverage files in your project. A thorough filename search will grab everything that is known to be a coverage report.

Here are some options for discovering reports:

# only upload this file
-f path/to/foo.bar

# also search this folder that is outside the project directory
-s /home/user/reports/foo/bar

# ignore all files at pattern *.bar
-f "!*.bar"

# include all files at pattern *.foo
-f "*.foo"

Uploading process

When the upload script is called, the general flow is as follows:

  1. The CI is discovered through environment variables.
  2. Language specific process (e.g. xcode, python).
  3. Reports are discovered.
  4. Reports are uploaded to cloud storage for archiving (secret location).
  5. Codecov is informed of the upload, and will queue the report processing server side.
  6. Done (exit 0).

Exit 0

Codecov will exit 0 to prevent failing the build, if there are issues. If you would like Codecov to exit with 1, use bash <(curl -s https://codecov.io/bash) -Z.

exit 0 is not foolproof. Please use this command to always exit with 0: bash <(curl -s https://codecov.io/bash) || echo 'Codecov failed to upload'.

Verbose mode

If there is an issue with the upload process, it helps to run in verbose mode. Supply the -v flag for better debugging output:

bash <(curl -s https://codecov.io/bash) -v

Codecov Bash uploader


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.