For the complete documentation index, see llms.txt. This page is also available as Markdown.

Install and Configure Harness CLI (hc)

Install, configure, and upgrade Harness CLI (hc) v1.x.x for Artifact Registry workflows.

Harness CLI (hc) v1.x.x is a command-line interface that only works with Harness Artifact Registry workflows. It enables you to manage artifact registry resources and automate common artifact management tasks directly from your terminal.

This section covers installation, configuration, and upgrade of the Harness CLI for Artifact Registry workflows.

Installation

Install the Harness CLI on Unix-based systems (macOS, Linux) using the following command:

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

This script will download and install the latest version of the CLI to your system.

Version Check

After installing the CLI, verify the installation by checking the version:

hc version

Example output:

Upgrade to Latest Version

To ensure you have the latest features and bug fixes, upgrade the Harness CLI to the latest version:

Authentication Setup

To authenticate the CLI with your Harness account, use the login command:

Auth Login form

You will be prompted to provide the following details:

  • URL: Your Harness platform URL

  • API Token Key: Your personal access token or API key (learn how to create API keys)

  • Account ID: Your Harness account identifier

  • Organization ID: Your organization identifier (optional)

  • Project ID: Your project identifier (optional)

Once authenticated, the CLI will store your credentials securely for subsequent commands.

GETTING HELP

Use hc [command] --help to get more information about any command. This will display available options, flags, and usage examples for the specified command.

Basic Verification

After authentication, verify your connection by performing a basic operation, for example, listing your registries:

This command should display your available registries, confirming a successful connection. Registry List

Using the CLI Binary

If you've downloaded the CLI binary directly, you may need to run it using ./hc from the directory where it's located:

Adding to PATH

To use hc from anywhere without the ./ prefix, add the CLI binary to your system PATH:

macOS/Linux:

  1. Move the binary to a directory in your PATH (e.g., /usr/local/bin):

  2. Make sure it's executable:

  3. Verify you can now use hc from anywhere:

Alternative: Add to PATH without moving

If you prefer to keep the binary in its current location, add that directory to your PATH:

To make this permanent, add the above line to your shell configuration file (~/.bashrc, ~/.zshrc, or ~/.bash_profile).

Last updated

Was this helpful?