Skip to main content

generic-quickstart

Last updated on

Use a Generic repository to store raw files like zip, war and tar files, test reports and configuration files. While it is not necessarily used for binaries, you can store binaries as well.

Prerequisites

  • Access to a Harness account with appropriate permissions to create registries and connectors.

Create a Generic Artifact Registry


Configure an Upstream Proxy (Optional)

An upstream proxy allows your registry to fetch artifacts from external sources if they are not available locally.

Create an upstream proxy

Configure the upstream proxy in your registry


Generic Client Setup

Follow these instructions to upload, download, and manage Generic artifacts using curl commands.

Generate Identity Token

An identity token will serve as the password for uploading and downloading artifacts.

  1. Navigate to your Harness project.
  2. Go to Artifact Registry and select your Generic registry.
  3. Click on Setup Client or Authentication.
  4. Generate an identity token (API key) that you'll use in the commands below.

Upload and Download Artifacts

Upload an Artifact

Use this curl command to push an artifact:

curl --location --request PUT 'https://pkg.harness.io/pkg/<ACCOUNT_ID>/<REGISTRY_NAME>/generic/<ARTIFACT_NAME>/<VERSION>' \
--form 'filename="<FILENAME>"' \
--form 'file=@"<FILE_PATH>"' \
--form 'description="<DESC>"' \
--header 'x-api-key: <API_KEY>'

Parameters:

  • <ACCOUNT_ID>: Your account identifier
  • <REGISTRY_NAME>: Name of your registry
  • <ARTIFACT_NAME>: Name of your artifact/package
  • <VERSION>: Version of the artifact
  • <FILENAME>: Name for the uploaded file
  • <FILE_PATH>: Local path to the file you want to upload
  • <DESC>: Optional description of the artifact
  • <API_KEY>: Your generated identity token

Download an Artifact

Use this curl command to download an artifact:

curl --location 'https://pkg.harness.io/pkg/<ACCOUNT_ID>/<REGISTRY_NAME>/generic/<ARTIFACT_NAME>/<VERSION>?filename=<FILENAME>' \
--header 'x-api-key: <API_KEY>' -J -O

Parameters:

  • <ACCOUNT_ID>: Your account identifier
  • <ARTIFACT_NAME>: Name of your artifact/package
  • <VERSION>: Version of the artifact
  • <FILENAME>: Name of the file to download
  • <API_KEY>: Your generated identity token

File Operations

These operations support both nested and flat file paths, allowing you to organize files within packages using directory structures.

Upload a File to a Specific Path

Upload a file to a specific path within the package:

curl -XPUT 'https://pkg.harness.io/pkg/<ACCOUNT_ID>/<REGISTRY_NAME>/generic/<ARTIFACT_NAME>/<VERSION>/<NESTED_FILE_PATH>' \
--header 'x-api-key: <API_KEY>' -T '<FILE_PATH>'

Example with nested path:

curl -XPUT 'https://pkg.harness.io/pkg/<ACCOUNT_ID>/<REGISTRY_NAME>/generic/<ARTIFACT_NAME>/<VERSION>/<NESTED_FILE_PATH>' \
--header 'x-api-key: <API_KEY>' -T '<FILE_PATH>'

Download a File from a Specific Path

Download a file from a specific path within the package:

curl --location 'https://pkg.harness.io/pkg/<ACCOUNT_ID>/<REGISTRY_NAME>/generic/<ARTIFACT_NAME>/<VERSION>/<NESTED_FILE_PATH>' \
--header 'x-api-key: <API_KEY>' -J -O

Get File Metadata

Retrieve file metadata using a HEAD request:

curl --location --head 'https://pkg.harness.io/pkg/<ACCOUNT_ID>/<REGISTRY_NAME>/generic/<ARTIFACT_NAME>/<VERSION>/<NESTED_FILE_PATH>' \
--header 'x-api-key: <API_KEY>'

Delete a File

Delete a file from a specific path within the package:

curl --location --request DELETE 'https://pkg.harness.io/pkg/<ACCOUNT_ID>/<REGISTRY_NAME>/generic/<ARTIFACT_NAME>/<VERSION>/<NESTED_FILE_PATH>' \
--header 'x-api-key: <API_KEY>'
Nested vs Flat Paths

File operations support both nested paths (e.g., config/prod/settings.json) and flat paths (e.g., settings.json), giving you flexibility in how you organize your artifacts.