{"id":5882,"library":"codecov-cli","title":"Codecov CLI","description":"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`.","status":"active","version":"11.2.8","language":"en","source_language":"en","source_url":"https://github.com/codecov/codecov-cli","tags":["codecov","cli","coverage","testing","ci-cd"],"install":[{"cmd":"pip install codecov-cli","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[],"quickstart":{"code":"import os\nimport subprocess\n\n# Ensure you have a CODECOV_TOKEN set as an environment variable or replace 'os.environ.get(...)'\n# with your actual token for testing purposes.\n# For CI/CD, it's highly recommended to use environment variables.\ncodecov_token = os.environ.get('CODECOV_TOKEN', 'your_codecov_upload_token_here')\n\nif not codecov_token or codecov_token == 'your_codecov_upload_token_here':\n    print(\"Warning: CODECOV_TOKEN not set or using placeholder. Uploads may fail.\")\n\n# Example: Running a simplified upload process (requires a coverage report file, e.g., coverage.xml)\n# In a real scenario, you would generate a coverage report first (e.g., with pytest-cov).\n# For this example, we assume 'coverage.xml' exists in the current directory.\n# To make this runnable, let's create a dummy coverage.xml if it doesn't exist.\nif not os.path.exists('coverage.xml'):\n    with open('coverage.xml', 'w') as f:\n        f.write('<coverage><packages><package name=\"my_module\"><file name=\"my_module.py\"></file></package></packages></coverage>')\n    print(\"Created dummy coverage.xml for quickstart.\")\n\ncommand = [\n    'codecovcli',\n    'upload-process',\n    '--token',\n    codecov_token,\n    '-f', 'coverage.xml' # Specify a coverage report file\n]\n\ntry:\n    print(f\"Running command: {' '.join(command)}\")\n    result = subprocess.run(command, check=True, capture_output=True, text=True)\n    print(\"Codecov CLI output:\")\n    print(result.stdout)\n    if result.stderr:\n        print(\"Codecov CLI errors:\")\n        print(result.stderr)\n    print(\"Codecov CLI command executed successfully.\")\nexcept subprocess.CalledProcessError as e:\n    print(f\"Error running Codecov CLI: {e}\")\n    print(f\"Stdout: {e.stdout}\")\n    print(f\"Stderr: {e.stderr}\")\n    print(\"Please ensure 'codecov-cli' is installed and CODECOV_TOKEN is correctly configured.\")\nexcept FileNotFoundError:\n    print(\"Error: 'codecovcli' command not found. Is codecov-cli installed and in your PATH?\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Refer to the `getsentry/prevent-cli` repository for the most current information regarding `codecov-cli` changes and releases.","message":"The `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.","severity":"gotcha","affected_versions":"10.0.4 onwards (PyPI versions)"},{"fix":"Consult the latest Codecov documentation for recommended practices for local coverage analysis and interaction.","message":"Commands related to 'local upload' have been deprecated as of version 10.4.0. Users should transition to alternative workflows for local coverage checks.","severity":"deprecated","affected_versions":">=10.4.0"},{"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.","message":"For 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Older 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.","severity":"breaking","affected_versions":"<4.0.0 of Codecov CI integration tools"},{"fix":"Ensure your CI environment or local machine has Git installed and that `codecovcli` is run from the root of your Git repository.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}