generic-quickstart
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
- Interactive Guide
- Step-by-Step
- Navigate to the Artifact Registry module in your Harness project.
- Click on New Artifact Registry.
- In the Registry Type dropdown, select Generic Registry.
- Provide a Registry Name.
- Optionally, add a Description and Labels for better organization.
- Choose visibility between Public and Private.
- Click Create Registry to finalize.
Your registry name must start with a letter and can include lowercase alphanumerics, _, . and -.
Configure an Upstream Proxy (Optional)
An upstream proxy allows your registry to fetch artifacts from external sources if they are not available locally.
- Interactive Guide
- Step-by-Step
Create an upstream proxy
Configure the upstream proxy in your registry
Create an upstream proxy
- Navigate to the Artifact Registry module in your Harness project.
- Click on New Artifact Registry.
- In the Registry Type dropdown, select Generic Registry.
- Provide a Registry Name.
- Optionally, add a Description and Labels for better organization.
- Choose visibility between Public and Private.
- Provide the URL of the custom source for your Remote registry.
When configuring a custom upstream URL, it's important to understand how the URL structure impacts artifact resolution and download paths. The custom URL you provide serves as the base path, and the registry automatically appends the artifact name and version to construct the complete download URL.
Your custom URL should point to a publicly accessible location with a logical folder structure where artifacts are stored.
Example: If you configure your custom URL as:
https://www.nuget.org/api/v2/package/
When downloading artifact Newtonsoft.Json version 10.0.3, the registry resolves to:
https://www.nuget.org/api/v2/package/Newtonsoft.Json/10.0.3
Include the complete API path and folder structure in your custom URL. This way, you only need to specify the artifact name and version during download operations, keeping your workflow clean and consistent.
- Click Create Registry to finalize.
Your registry name must start with a letter and can include lowercase alphanumerics, _, . and -.
Configure the upstream proxy in your registry
- Navigate to the Artifact Registry module in your Harness project.
- Select an existing Artifact Registry.
- Select the Configuration tab.
- Under Advanced (Optional), select Configure Upstream.
- Select from the list of compatible proxies to add them to your registry.
- Click Save to save the configuration.
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.
- Navigate to your Harness project.
- Go to Artifact Registry and select your Generic registry.
- Click on Setup Client or Authentication.
- 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>'
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.