CLI Options

All of the ways you can customize your Codecov experience via CLI

Once your CLI Installation is successful, there are additional commands and customizations possible.

📘

Usage

Running codecovcli --help will output the available commands along with the different general options that can be used with them.

Usage: codecovcli [OPTIONS] COMMAND [ARGS]...

User Inputs

Codecov-cli supports inputs. These inputs, along with their descriptions and usage contexts, are listed in the table below:

InputDescriptionUsage
--auto-load-params-fromThe CI/CD platformOptional
--codecov-yml-pathThe path for your codecov.ymlOptional
--enterprise-urlChange the upload host (Enterprise use)Optional
--versionCodecov-cli's versionOptional
--verbose or -vRun the cli with verbose loggingOptional

Codecov-cli Commands

CommandDescription
create-commitSaves the commit's metadata in codecov, it's only necessary to run this once per commit
create-reportCreates an empty report in codecov with initial data e.g. report name, report's commit
do-uploadSearches for and uploads coverage data to codecov
create-report-resultsUsed for local upload. It tells codecov that you finished local uploading and want it to calculate the results for you to get them locally.
get-report-resultsUsed for local upload. It asks codecov to provide you the report results you calculated with the previous command.
pr-base-pickingTells codecov that you want to explicitly define a base for your PR

Note: Every command has its own different options that will be mentioned later in this doc. Codecov will try to load these options from your CI environment variables, if not, it will try to load them from git, if not found, you may need to add them manually.

create-commit

codecovcli create-commit [Options]

OptionDescriptionUsage
-C, --sha, --commit-shaCommit SHA (with 40 chars)Required
--parent-shaSHA (with 40 chars) of what should be the parent of this commitOptional
-P, --pr, --pull-request-numberSpecify the pull request number manually. Used to override pre-existing CI environment variablesOptional
-B, --branchBranch to which this commit belongs toOptional
-r, --slugowner/repo slug used instead of the private repo token in Self-hostedRequired
-t, --tokenCodecov upload tokenRequired
--git-serviceGit Provider. Options: github, gitlab, bitbucket, github_enterprise, gitlab_enterprise, bitbucket_serverRequired
--helpShows usage, and command options

create-report

codecovcli create-report [OPTIONS]

OptionDescriptionUsage
-C, --sha, --commit-shaCommit SHA (with 40 chars)Required
-r, --slugowner/repo slug used instead of the private repo token in Self-hostedRequired
-t, --tokenCodecov upload tokenRequired
--git-serviceGit Provider. Options: github, gitlab, bitbucket, github_enterprise, gitlab_enterprise, bitbucket_serverRequired
--codeThe code of the report. This is used in local uploading to isolate local reports from regular or cloud reports uploaded to codecov so they don't get merged. It's basically a name you give to your report e.g. local-report.Optional
--helpShows usage, and command options

do-upload

codecovcli do-upload [OPTIONS]

OptionDescriptionUsage
-C, --sha, --commit-shaCommit SHA (with 40 chars)Required
--report-codeThe code of the report defined when creating the report. If unsure, leave defaultOptional
--network-root-folderRoot folder from which to consider paths on the network section default: (Current working directory)Optional
-s, --dir, --coverage-files-search-root-folderFolder where to search for coverage files default: (Current Working Directory)Optional
--exclude, --coverage-files-search-exclude-folderFolders to exclude from searchOptional
-f, --file, --coverage-files-search-direct-fileExplicit files to uploadOptional
-b, --build, --build-codeSpecify the build number manuallyOptional
--build-urlThe URL of the build where this is runningOptional
--job-codeThe job code for the CI runOptional
-t, --tokenCodecov upload tokenRequired
-n, --nameCustom defined name of the upload. Visible in Codecov UIOptional
-B, --branchBranch to which this commit belongs toOptional
-r, --slugowner/repo slugRequired
-P, --pr, --pull-request-numberSpecify the pull request number manually. Used to override pre-existing CI environment variablesOptional
-e, --env, --env-varSpecify environment variables to be included with this build.Optional
-F, --flagFlag the upload to group coverage metrics. Multiple flags allowed.Optional
--pluginplugins to run. Options: xcode, gcov, pycoverage. The default behavior runs them all. noop disables allOptional
-Z, --fail-on-errorExit with non-zero code in case of error uploading.Optional
-d, --dry-runDon't upload files to CodecovOptional
--legacy, --use-legacy-uploaderUse the legacy upload endpointOptional
--git-serviceGit Provider. Options: github, gitlab, bitbucket, github_enterprise, gitlab_enterprise, bitbucket_serverRequired
--disable-file-fixesDisable file fixes to ignore common lines from coverage (e.g. blank lines or empty brackets)Optional
--helpShows usage, and command options

create-report-results

codecovcli create-report-results [OPTIONS]

OptionDescriptionUsage
--commit-shaCommit SHA (with 40 chars)Required
--codeThe code of the report. If unsure, leave defaultRequired
--slugowner/repo slugRequired
--git-serviceGit provider. Options: github, gitlab, bitbucket, github_enterprise, gitlab_enterprise, bitbucket_serverOptional
-t, --tokenCodecov upload tokenRequired
--helpShows usage, and command options

get-report-results

codecovcli get-report-results [OPTIONS]

OptionDescriptionUsage
--commit-shaCommit SHA (with 40 chars)Required
--codeThe code of the report. If unsure, leave defaultRequired
--slugowner/repo slugRequired
--git-serviceGit provider. Options: github, gitlab, bitbucket, github_enterprise, gitlab_enterprise, bitbucket_serverOptional
-t, --tokenCodecov upload tokenRequired
--helpShows usage, and command options

pr-base-picking

codecovcli pr-base-picking [OPTIONS]

OptionDescriptionUsage
--base-shaBase commit SHA (with 40 chars)Required
--prPull Request id to associate commit withRequired
--slugowner/repo slugRequired
-t, --tokenCodecov upload tokenRequired
--serviceGit provider. Options: github, gitlab, bitbucket, github_enterprise, gitlab_enterprise, bitbucket_serverOptional
--helpShows usage, and command options

send-notifications

codecovcli send-notifications

Codecov doesn't intrinsically know when you have finished making uploads for a commit, this allows you to tell us. When this is enabled we'll send one PR comment and you'll be notified just one time that we've posted a comment (if you have notifications for PR comments turned on in your code host of choice).

This particular command also needs a corresponding Codecov yaml setting:

codecov:
	notify:
		manual trigger: true

empty-upload

Used if the changes made don't need testing, but PRs require a passing Codecov status to be merged.
This command will scan the files in the commit and send passing status checks configured if all the changed files
are ignored by Codecov (including README and configuration files)

Usage: codecovcli empty-upload [OPTIONS]

OptionDescriptionUsage
-C, --sha, --commit-shaBase commit SHA (with 40 chars)Required
-t, --tokenCodecov upload tokenRequired
-r, --slugowner/repo slug (used instead of the private repo token in Self-hosted)Optional
--git-serviceGit provider. Options: github, gitlab, bitbucket, github_enterprise, gitlab_enterprise, bitbucket_serverOptional
-Z, --fail-on-errorExit with non-zero code in case of errorOptional
--helpShow this message and exit.Optional

How to Use Local Upload

The CLI also supports "dry run" local uploading. This is useful if you prefer to see Codecov status checks and coverage reporting locally, in your terminal, as opposed to opening a PR and waiting for your full CI to run. Local uploads do not interfere with regular uploads made from your CI for any given commit / Pull Request.

Local Upload is accomplished as follows:

pip install codecov-cli
codecovcli create-commit
codecovcli create-report --code <CODE>
codecovcli do-upload --report-code <CODE>
codecovcli create-report-results --code <CODE>
codecovcli get-report-results --code <CODE>

Codecov will calculate the coverage results, and return them in your terminal, telling you whether your PR will fail or pass the coverage check.

Note: In order for Local Upload to work, it must be used against a commit on the origin repository. Local Upload does not work for arbitrary diffs or uncommitted changes on your local machine.