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 | shConfirm the installation and add hc to your PATH as prompted, then verify:
hc versionTo upgrade to the latest version:
hc upgradeAuthenticate interactively:
hc auth loginYou 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_IDGlobal flags
These flags apply to every hc command and override the values stored from hc auth login.
--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.
--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.
--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
--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.
-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:
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
Examples:
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.
--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.
-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.
--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
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.
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.
--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
Examples:
hc artifact copy
Copy a specific artifact version from one registry to another within the same Harness account.
--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
Next steps
Last updated
Was this helpful?