Skip to main content

Manage Artifacts and Registries

This guide covers the essential commands for working with the Artifact Registry from the command line.

Registry Management

The hc registry (or hc reg) command allows you to manage your Artifact Registry registries.

List Registries

View all registries in your project:

hc registry list --org devrel --project sd1

You can also use the short alias:

hc reg list --org devrel --project sd1 
Registry List

This displays a table with your registries, including their identifiers, package types, and other details provided that your authentication is at account level.

Get Registry Details

Retrieve detailed information about a specific registry:

hc registry get [?name] [flags]

Available flags:

  • --package-type string package type
  • --page int32 page number (zero-indexed)
  • --page-size int32 number of items per page (default 10)

Go to the Artifact Registry documentation for a comprehensive list of supported package types.

You can also use global flags to override the org and project, to know more about global flags, refer to the Global Flags section.

Artifact Management

The hc artifact (or hc art) command allows you to manage artifacts within your registries.


List Artifacts

The list command is hierarchical and can show different levels of detail depending on the arguments provided.

List Artifacts

hc artifact list [flags]

Shows all available artifacts in your project.


List All Artifacts in a Registry

This will show all artifacts in the specified registry.

hc artifact list --registry <registry> --org <org> --project <project>

Example:

hc artifact list --registry hub01 --org devrel --project sd1 
Get Artifact from Registry

Pagination Options

For large result sets, control the output with pagination:

hc artifact list --registry <registry> --page 0 --page-size 20

Available flags:

  • --page: Page number (zero-indexed)
  • --page-size: Number of items per page (default: 10)
  • --registry: Name of the registry

Push Artifacts

Push artifacts to your registry using the appropriate subcommand for your package type.

General syntax:

hc artifact push [command]

Available commands:

  • generic
  • go
  • maven
  • conda

Pick the appropriate command based on your package type. Use the -h flag to get help and understand the necessary flags for each command.

Example: Push a generic artifact

hc artifact push go my-go-registry v1.2.3

Pull Artifacts

Download artifacts from your registry to your local machine.

General syntax:

 hc artifact pull [command]

Available commands:

  • generic

Pick the appropriate command based on your package type. Use the -h flag to get help and understand the necessary flags for each command.

Example with package URL:

hc artifact pull generic image cli-arti/latest/package.json ./dummy --pkg-url https://pkg.harness.io 
Pull Generic Artifact

This downloads the specified artifact to the destination path on your local machine.

Tips and Best Practices

1. Use Command Aliases

Save time with short aliases:

  • hc reg instead of hc registry
  • hc art instead of hc artifact

2. Get Help Anytime

Use the --help flag to see all available options:

hc [command] --help
hc registry list --help

3. Pagination for Large Datasets

Control output when working with many artifacts:

hc artifact list my-registry --page-size 50

4. Scripting and Automation

Use JSON or YAML format for parsing in scripts:

hc registry list --format json | jq '.[] | .identifier'

5. Work Across Projects

Use global flags to work with different projects without changing configuration:

hc registry list --project dev-project
hc registry list --project prod-project