Registry / devops / codecov-cli

codecov-cli

JSON →
library11.2.8pypypiunverified

Codecov CLI (Command Line Interface) is a Python-based tool designed to allow users to interact with Codecov directly from their terminal or CI platform. It enables features like saving commit metadata, creating coverage reports, uploading coverage data, and more. The current version is 11.2.8, and it maintains an active development and release cadence, though its underlying codebase has migrated to a sub-project within `getsentry/prevent-cli`.

pip install codecov-cli
INSTALL
IMPORT
SIG · CODECOV-CLI
C
codecov-cli
devopspythonv11.2.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

This quickstart demonstrates how to run the `codecovcli upload-process` command using Python's `subprocess` module. It emphasizes the critical role of the `CODECOV_TOKEN` environment variable for authentication and shows how to specify a coverage report file. Ensure you have a `coverage.xml` (or similar) file generated by your test runner.

import os import subprocess # Ensure you have a CODECOV_TOKEN set as an environment variable or replace 'os.environ.get(...)' # with your actual token for testing purposes. # For CI/CD, it's highly recommended to use environment variables. codecov_token = os.environ.get('CODECOV_TOKEN', 'your_codecov_upload_token_here') if not codecov_token or codecov_token == 'your_codecov_upload_token_here': print("Warning: CODECOV_TOKEN not set or using placeholder. Uploads may fail.") # Example: Running a simplified upload process (requires a coverage report file, e.g., coverage.xml) # In a real scenario, you would generate a coverage report first (e.g., with pytest-cov). # For this example, we assume 'coverage.xml' exists in the current directory. # To make this runnable, let's create a dummy coverage.xml if it doesn't exist. if not os.path.exists('coverage.xml'): with open('coverage.xml', 'w') as f: f.write('<coverage><packages><package name="my_module"><file name="my_module.py"></file></package></packages></coverage>') print("Created dummy coverage.xml for quickstart.") command = [ 'codecovcli', 'upload-process', '--token', codecov_token, '-f', 'coverage.xml' # Specify a coverage report file ] try: print(f"Running command: {' '.join(command)}") result = subprocess.run(command, check=True, capture_output=True, text=True) print("Codecov CLI output:") print(result.stdout) if result.stderr: print("Codecov CLI errors:") print(result.stderr) print("Codecov CLI command executed successfully.") except subprocess.CalledProcessError as e: print(f"Error running Codecov CLI: {e}") print(f"Stdout: {e.stdout}") print(f"Stderr: {e.stderr}") print("Please ensure 'codecov-cli' is installed and CODECOV_TOKEN is correctly configured.") except FileNotFoundError: print("Error: 'codecovcli' command not found. Is codecov-cli installed and in your PATH?")
codecovcli --version
Debug
Known issues
gotchaThe `codecov-cli` codebase has migrated from `codecov/codecov-cli` to a sub-project within `getsentry/prevent-cli`. This means that changelogs and GitHub releases for the original `codecov-cli` repository may not be up-to-date with PyPI releases, making it challenging to track changes.
fix
Refer to the `getsentry/prevent-cli` repository for the most current information regarding `codecov-cli` changes and releases.
affects: 10.0.4 onwards (PyPI versions)
deprecatedCommands related to 'local upload' have been deprecated as of version 10.4.0. Users should transition to alternative workflows for local coverage checks.
fix
Consult the latest Codecov documentation for recommended practices for local coverage analysis and interaction.
affects: >=10.4.0
gotchaFor most use cases, particularly with private repositories, `codecov-cli` requires an upload token (`CODECOV_TOKEN`) for authentication. Tokenless uploads are primarily limited to forks creating pull requests on public repositories.
fix
Obtain a Codecov upload token from your repository settings on Codecov.io and set it as the `CODECOV_TOKEN` environment variable or pass it directly via the `-t` or `--token` CLI argument.
affects: All versions
breakingOlder versions of Codecov CI integration tools (e.g., GitHub Action, CircleCI Orb, Bitrise Step) that did not internally use `codecov-cli` are no longer supported. Users leveraging these integrations must update to version 4.0.0 or later of their respective CI uploader to benefit from `codecov-cli`'s features and continued support.
fix
Update your CI/CD workflow configurations to use version 4.0.0 or newer of the Codecov GitHub Action, CircleCI Orb, or Bitrise Step.
affects: <4.0.0 of Codecov CI integration tools
gotchaThe Codecov CLI expects to be executed within a checked-out Git repository and requires `git` to be installed on the machine where it runs to correctly infer repository metadata.
fix
Ensure your CI environment or local machine has Git installed and that `codecovcli` is run from the root of your Git repository.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'codecovcli' OR codecov: command not found
After installing `codecov-cli` via pip, users might mistakenly try to execute it using the command `codecov` instead of the correct executable name `codecovcli`, or Python's script directory might not be in the system's PATH.
fix
Use the command `codecovcli` instead of `codecov`. If that doesn't work, try `python -m codecov_cli` or ensure your Python environment's script path is included in your system's PATH variable.
Error uploading to https://codecov.io: Error: There was an error fetching the storage URL during POST: 404 - {'detail': 'Could not find a repository, try using repo upload token'} OR Upload failed: {"message":"Repository not found"}
This error occurs when Codecov cannot identify the repository associated with the upload, often due to a missing or invalid upload token, insufficient permissions for private repositories, or GitHub API rate limits affecting public repositories without the Codecov app installed.
fix
Ensure a valid Codecov upload token is set as an environment variable (e.g., `CODECOV_TOKEN`) or passed directly using the `-t` or `--token` flag. For public repositories, installing the Codecov GitHub app can help bypass rate limit issues. Verify the repository slug (`owner/repo`) is correctly configured or auto-detected.
There was an error processing coverage report OR Unusable report OR Codecov UI reports an error, but my upload was successful
The `codecov-cli` might report a successful upload, but Codecov's backend fails to process the report because it's empty, malformed, in an unsupported format, or due to an internal processing issue.
fix
Verify that your test suite correctly generated a non-empty coverage report in a supported format (e.g., `coverage.xml`). Run `codecovcli` with the `--verbose` and `--fail-on-error` flags to get more diagnostic information and ensure your CI/CD pipeline fails if the CLI encounters an issue.
Config file codecov.yml not found, or is not a file. Ignoring config.
The `codecov-cli` could not find the `codecov.yml` configuration file in its default search paths (e.g., repository root, `.github/`).
fix
Ensure your `codecov.yml` file is placed in the root of your repository or specify its exact path using the `--codecov-yml-path` command-line option when running `codecovcli`.
No reports found.
The `codecov-cli` could not locate any coverage report files (e.g., `coverage.xml`, `lcov.info`) in the default search paths or the specified path.
fix
Ensure your test runner (e.g., `pytest-cov`, `jest`) generates a coverage report before `codecov-cli` runs, and if the report is not in a standard location, specify its path using the `-f` flag, e.g., `codecov upload -f ./coverage.xml`.
Upgrade
Version history
11.2.8latest on PyPI · released Mar 26, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
37 hits · last 30 days
node
34
OpenAI (training)
1
Resources
codecov-cli — pip install codecov-cli · libregistry