Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.
Hc CliReferenceAutomation

CLI

Full command reference for the Harness CLI (hc): managing registries, artifacts, and Dependency Firewall from the terminal or a CI pipeline.

The Harness CLI (hc) lets you manage Artifact Registry resources from the terminal or a CI pipeline. Use it to create and configure registries, push and pull artifacts, audit dependencies against firewall policies, and automate registry operations.

Install and authenticate

Install on macOS or Linux:

curl https://raw.githubusercontent.com/harness/harness-cli/v2/install | sh

Confirm the installation and add hc to your PATH as prompted, then verify:

hc version

To upgrade to the latest version:

hc upgrade

Authenticate interactively:

hc auth login

You are prompted for your Harness URL (https://app.harness.io), API token, and account ID. Optionally scope the session to a default org and project. Credentials are stored locally after a successful login.

Authenticate non-interactively (CI):

hc auth login \
  --api-url https://app.harness.io \
  --api-token $HARNESS_API_TOKEN \
  --account $HARNESS_ACCOUNT_ID

Global flags

These flags apply to every hc command and override the values stored from hc auth login.

Flag
Description

--account

Account ID

--api-url

Base Harness API URL

--org

Organization ID

--project

Project ID

--token

Authentication token (overrides stored credentials). Note: hc auth login uses --api-token instead; see Install and authenticate above.

--format

Output format: table (default), json, yaml

-v, --verbose

Verbose console output

-h, --help

Help for the current command

Short aliases: hc reg = hc registry · hc art = hc artifact


hc registry

The hc registry command group manages registries in Harness Artifacts.

hc registry list

List all registries in a project.

Flag
Description

--org

Organization ID

--project

Project ID

--format

Output format: table, json, yaml

Example:

Extract identifiers for scripting:

hc registry get

Retrieve details about a registry: type, configuration, and artifact count.

Flag
Description

--package-type

Filter by package type

--page

Page number, zero-indexed (default 0)

--page-size

Results per page (default 10)

Example:

hc registry configure

Configure a package manager client to authenticate and route traffic through a Harness Artifacts. The command writes the registry URL and credentials to your package manager's config file: .npmrc for npm, ~/.m2/settings.xml for Maven, and so on. After running this, use your native package manager commands directly.

Supported package managers: npm · maven · pip · nuget

Flag
Required
Description

--registry

Yes

Registry identifier

--pkg-url

No

Package host URL (default: https://pkg.harness.io)

--scope

No

npm scope, e.g. @myorg; configures a scoped registry

--global

No

Write to ~/.npmrc (user-global)

--project-level

No

Write .npmrc in the current directory

Writes the registry URL and credentials to ~/.m2/settings.xml.

Configures pip to resolve packages from the registry.

Configures the NuGet / dotnet client.

hc registry metadata

Attach custom key-value labels to a registry for organization, search, and automation.

Set:

Get:

Delete:

Example:

hc registry fw audit

Evaluate a dependency manifest or lock file against your registry's Dependency Firewall policies. Use this locally before a PR or in CI before deployment to surface blocked and flagged packages before they reach production.

Flag
Required
Description

-f, --file

Yes

Path to manifest or lock file

--registry

Yes

Registry name

--org

No

Organization ID

--project

No

Project ID

Input files and what they audit:

Input file
Audit scope

package.json

Direct dependencies only

package-lock.json, yarn.lock, pnpm-lock.yaml

Direct and all transitive dependencies

pom.xml, build.gradle, requirements.txt, and other manifests

Per package manager resolution

Pass a lock file to audit the full resolved dependency graph, including transitive packages. Pass package.json to audit direct dependencies only.

Examples:

If lock files are not stored in source control, generate one before auditing:

For other package managers: yarn install, pnpm install --lockfile-only, or the equivalent for your tool.

Sample output:

hc registry fw explain

Get the Dependency Firewall verdict and scan details for a specific artifact version already stored in a registry. Use this to investigate why a package was allowed, blocked, or flagged.

Flag
Required
Description

--registry

Yes

Registry name

--package

Yes

Package name

--version

Yes

Package version

Example:

Possible statuses: ALLOWED · BLOCKED · WARN

hc registry migrate

Migrate artifacts from an external registry to Harness Artifacts using a YAML config file. Supported source types: NEXUS, JFROG.

Flag
Description
Default

-c, --config

Path to migration config file

config.yaml

--concurrency

Concurrent operations

1

--dry-run

Preview file list without uploading

false

--overwrite

Overwrite existing artifacts

false

-v, --verbose

Verbose logging

false

Go to Migrate from JFrog Artifactory and Migrate from Amazon ECR for complete migration guides including config file structure and step-by-step walkthroughs.

hc registry delete

Delete a registry and all artifacts within it.

Example:


hc artifact

The hc artifact command group manages artifacts within your registries.

hc artifact list

List artifacts in a registry, with optional pagination.

Flag
Description

--registry

Registry name

--page

Page number, zero-indexed

--page-size

Results per page (default 10)

Examples:

hc artifact push

Push an artifact to a registry. Use the subcommand for your package type.

Supported package types: generic · go · conda · cargo · composer · dart · nuget · python · rpm · npm · swift

Use -h on any subcommand for its full flag list:

Example: generic artifact

For single-file uploads (Generic, Composer, RPM, Python, Dart), the CLI automatically sends a checksum digest with the request. The registry rejects uploads where the bytes do not match and returns 409 Conflict. No configuration is required.

hc artifact pull

Download an artifact from a registry to your local machine.

Supported package types: generic

Example:

Install wrappers with Dependency Firewall tracking

These commands wrap your native package manager's install to add Dependency Firewall evaluation and dependency graph upload. After the install, the Dependency Firewall dashboard shows which packages were blocked and which pipelines are affected.

Command
Wraps

hc artifact npm install

npm install

hc artifact npm ci

npm ci

hc artifact mvn install

mvn install

hc artifact pip install

pip install

hc artifact dotnet restore

dotnet restore

Prerequisites: Authenticate with hc auth login and configure your package manager with hc registry configure. Dependency Firewall must be enabled on the registry.

Example: npm

Example output:

Go to Dependency Firewall for dashboard details and pipeline tracking.

hc artifact metadata

Attach custom key-value labels to an artifact package or a specific version.

Set:

Get:

Delete:

Omit --version to operate at package level. Include --version to operate on a specific version.

Examples:

hc artifact delete

Delete an artifact or specific versions from a registry. Supports wildcard patterns for bulk operations.

Flag
Required
Description
Default

--registry

Yes

Registry name

None

--version

No

Version to delete; supports glob patterns (e.g. 1.0.*)

All versions

--dry-run

No

Preview without deleting

true

--force

No

Permanent delete; omit for soft delete

false

--dry-run defaults to true. Pass --dry-run=false when you are ready to execute; without it, the command only previews what would be deleted.

Examples:

hc artifact copy

Copy a specific artifact version from one registry to another within the same Harness account.

Flag
Description

--artifact-type

Artifact type, e.g. model or dataset

Example:


Use the CLI in CI

Jenkins

Install the Harness plugin for Jenkins. The plugin installs and authenticates hc on the agent. Configure the CLI tool under Manage Jenkins > Tools and store your API token under Manage Jenkins > System.

GitHub Actions

Use the Setup Harness CLI action. Store your credentials as GitHub secrets.

The action logs out at job end, even on failure, so the token is not left on self-hosted runners.


Troubleshooting

hc auth login fails or returns 401

Verify your API token is valid and has not expired. Confirm the account ID matches the account associated with the token. Pass --api-url https://app.harness.io explicitly if the stored URL is incorrect.

hc registry list returns no results

Confirm --org and --project match where your registries are created. Run hc auth login to refresh your session if the token has expired.

Push returns 409 Conflict

A 409 from a single-file push means the uploaded content did not match the declared checksum. Re-upload the file. If the error persists, verify the file was not modified during transfer.

hc registry fw audit shows no results

Confirm the input file format is supported: package-lock.json, yarn.lock, or pnpm-lock.yaml for npm; pom.xml or build.gradle for Maven; requirements.txt or Pipfile.lock for Python. Dependency Firewall must be enabled on the registry.

Does the CLI support yarn install or npm audit?

hc artifact npm install does not wrap yarn install. To audit yarn dependencies against Dependency Firewall, run hc registry fw audit --file yarn.lock --registry <name>. For npm audit, the npm client handles that natively against the registry; those results show vulnerability advisory data, not Dependency Firewall decisions.

Next steps

Last updated

Was this helpful?