A Drone plugin for managing generic artifacts in Harness Artifact Registry (HAR) using the Harness CLI. Supports multiple operations including upload, download, info retrieval, and deletion.
This plugin provides a comprehensive way to manage artifacts in Harness Artifact Registry as part of your Drone CI/CD pipeline. It uses the Harness CLI (hc) internally to handle authentication and supports multiple operations:
- Push: Upload artifacts to the registry
- Pull: Download artifacts from the registry
- Get: Retrieve artifact information
- Delete: Remove artifacts from the registry
kind: pipeline
type: docker
name: default
steps:
- name: upload-artifact
image: harness/drone-har
settings:
command: push # Optional - defaults to push
registry: my-registry
source: ./dist/my-app.zip
name: my-application
version: 1.0.0
token:
from_secret: harness_token
account:
from_secret: harness_account
org: my-org
project: my-project
pkg_url: https://pkg.qa.harness.iokind: pipeline
type: docker
name: artifact-management
steps:
# Upload artifact
- name: upload-artifact
image: harness/drone-har
settings:
command: push
registry: my-registry
source: ./build/artifact.tar.gz
name: my-service
version: ${DRONE_BUILD_NUMBER}
description: "Build artifact for ${DRONE_COMMIT_SHA}"
filename: "my-service-${DRONE_BUILD_NUMBER}.tar.gz"
token:
from_secret: harness_token
account:
from_secret: harness_account
org: my-org
project: my-project
pkg_url: https://pkg.qa.harness.io
enable_proxy: true
# Get artifact info
- name: get-artifact-info
image: harness/drone-har
settings:
command: get
registry: my-registry
name: my-service
version: ${DRONE_BUILD_NUMBER}
token:
from_secret: harness_token
account:
from_secret: harness_account
pkg_url: https://pkg.qa.harness.io
# Download artifact (in a different pipeline/stage)
- name: download-artifact
image: harness/drone-har
settings:
command: pull
registry: my-registry
name: my-service
version: 1.0.0
filename: my-service.tar.gz
destination: ./downloaded/
token:
from_secret: harness_token
account:
from_secret: harness_account
pkg_url: https://pkg.qa.harness.io| Setting | Description | Example |
|---|---|---|
registry |
Name of the Harness Artifact Registry | my-registry |
token |
Harness authentication token | pat.abc123... |
account |
Harness account ID | abc123def456 |
pkg_url |
Base URL for the Packages (push/pull only) | https://pkg.qa.harness.io |
| Setting | Description | Example |
|---|---|---|
source |
Path to the artifact file to upload | ./dist/app.zip |
name |
Name for the artifact in the registry | my-application |
| Setting | Description | Example |
|---|---|---|
name |
Name of the artifact to download | my-application |
version |
Version of the artifact to download | 1.0.0 |
filename |
Filename of the artifact to download | app.zip |
destination |
Local destination path for download | ./downloads/ |
| Setting | Description | Example |
|---|---|---|
name |
Name of the artifact to get info for | my-application |
| Setting | Description | Example |
|---|---|---|
name |
Name of the artifact to delete | my-application |
| Setting | Description | Default | Example | Commands |
|---|---|---|---|---|
command |
Operation to perform | push |
pull, get, delete |
All |
version |
Version for the artifact | 1.0.0 |
${DRONE_BUILD_NUMBER} |
push, get, delete |
description |
Description of the artifact | (empty) | Build artifact |
push |
filename |
Custom filename for the uploaded artifact | (basename of source) | app-v1.0.0.zip |
push |
package_type |
Type of package | generic |
generic |
push |
org |
Harness organization ID | (empty) | my-org |
All |
project |
Harness project ID | (empty) | my-project |
All |
api_url |
Base URL for the Harness API | (empty) | https://app.harness.io |
All |
enable_proxy |
Enable proxy configuration | false |
true |
All |
log_level |
Plugin log level | (empty) | debug |
All |
The plugin requires a Harness Personal Access Token (PAT) for authentication. You can create one in your Harness account settings.
Security Note: Always store your token as a Drone secret, never hardcode it in your pipeline configuration.
# Store as a secret
settings:
token:
from_secret: harness_tokenThe plugin uses the following environment variables (automatically set by Drone):
PLUGIN_COMMAND- Command to execute (push, pull, get, delete)PLUGIN_REGISTRY- Registry namePLUGIN_TOKEN- Authentication tokenPLUGIN_ACCOUNT- Account IDPLUGIN_PKG_URL- Base URL for packagesPLUGIN_ORG- Organization IDPLUGIN_PROJECT- Project IDPLUGIN_API_URL- API base URLPLUGIN_ENABLE_PROXY- Enable proxyPLUGIN_LOG_LEVEL- Log level
PLUGIN_SOURCE- Source file pathPLUGIN_NAME- Artifact namePLUGIN_VERSION- Artifact versionPLUGIN_DESCRIPTION- Artifact descriptionPLUGIN_FILENAME- Custom filenamePLUGIN_PACKAGE_TYPE- Package type
PLUGIN_NAME- Artifact namePLUGIN_VERSION- Artifact versionPLUGIN_FILENAME- Artifact filenamePLUGIN_DESTINATION- Destination path
PLUGIN_NAME- Artifact namePLUGIN_VERSION- Artifact version
The plugin supports proxy configuration through environment variables:
HARNESS_HTTP_PROXY- HTTP proxy URLHARNESS_HTTPS_PROXY- HTTPS proxy URLHARNESS_NO_PROXY- Comma-separated list of hosts to bypass proxy
Set enable_proxy: true in your pipeline settings to activate proxy support.
# Build the binary
go build -o drone-har
# Build Docker image
docker build -t harness/drone-har .# Run unit tests
make test
# or
go test ./...
# Run tests with coverage
make test-coverage
# or
go test -cover ./...
# Run integration tests (requires credentials)
export HARNESS_TOKEN="your-token"
export HARNESS_ACCOUNT="your-account"
export HARNESS_ORG="default"
export HARNESS_PROJECT="your-project"
make test-integration
# or
go test -tags=integration -v ./plugin/...
# Run all tests
make test-allSee TESTING.md for detailed testing documentation.
Uploads an artifact file to the registry.
Required: registry, source, name, token, account, pkg_url
Downloads an artifact from the registry.
Required: registry, name, version, filename, destination, token, account, pkg_url
Retrieves information about an artifact.
Required: registry, name, token, account
Deletes an artifact from the registry.
Required: registry, name, token, account
- Harness CLI (
hc) must be available in the container - Valid Harness authentication token
- Access to the target Harness Artifact Registry
This project is licensed under the Blue Oak Model License.