Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.
ReferenceAuthenticationHc Cli

Environment variables

Reference for every environment variable used with Harness Artifacts: authentication, CLI, pipeline context, package managers, and Terraform.

Environment variables let you configure Harness Artifacts clients and tooling without hard-coding credentials or account identifiers in scripts. This page lists every variable used across the CLI, package manager clients, CI integrations, and Terraform provider.

Core authentication variables

These variables authenticate you or a service account to Harness. Set them before running any hc CLI command, docker login, package manager configuration, or REST API call.

Variable
Description
Required

HARNESS_API_KEY

Harness personal access token (PAT) or service account token. Used as the password for all package manager clients (Docker, Helm, npm, Maven, pip, Cargo, NuGet) and as the x-api-key header for REST API calls.

Yes

HARNESS_ACCOUNT_ID

Your Harness account identifier. Appears in every registry URL (pkg.harness.io/pkg/<ACCOUNT_ID>/...) and in Terraform resource references.

Yes

HARNESS_EMAIL

The email address associated with your Harness account. Used as the username when authenticating Docker, Helm, Maven, pip, and similar clients.

Yes (for client auth)

HARNESS_URL

Base URL of the Harness platform. Defaults to https://app.harness.io for SaaS; set to your on-prem hostname for self-managed deployments.

Yes (for CLI and GitHub Actions)

Example: set core auth variables in a shell session

export HARNESS_ACCOUNT_ID="<your-account-id>"
export HARNESS_EMAIL="user@example.com"
export HARNESS_API_KEY="<your-pat>"
export HARNESS_URL="https://app.harness.io"

Example: GitHub Actions secrets

- uses: harness/artifacts-action@v1
  with:
    api-url: ${{ secrets.HARNESS_URL }}
    account: ${{ secrets.HARNESS_ACCOUNT_ID }}
    token: ${{ secrets.HARNESS_PAT_TOKEN }}

Store HARNESS_API_KEY (sometimes named HARNESS_PAT_TOKEN in GitHub Actions workflows) as a secret, not as a plain environment variable. Go to Authentication and identity tokens for guidance on token types and scopes.


hc CLI variables

The hc CLI reads these variables automatically when they are set. Command-line flags override them when both are present.

Variable
CLI flag equivalent
Description

HARNESS_API_TOKEN

--api-key

API token for all hc commands. Equivalent to HARNESS_API_KEY.

HARNESS_ACCOUNT_ID

--account-id

Account identifier.

HARNESS_URL

--url

Harness platform base URL.

The CLI accepts both HARNESS_API_TOKEN and HARNESS_API_KEY. If both are set, HARNESS_API_TOKEN takes precedence.

Go to CLI reference for a full list of commands and flags.


Dependency Firewall: pipeline context variables

When hc runs inside a Harness CI pipeline, it reads these variables automatically to link the dependency audit to the pipeline execution. The Dependency Firewall uses this context to populate the Affected Pipelines view.

Variable
Maps to
Description

HARNESS_PIPELINE_ID

Pipeline identifier

The pipeline that triggered the build.

HARNESS_BUILD_ID

Execution identifier

The specific run of the pipeline.

HARNESS_STAGE_ID

Stage identifier

The stage inside the pipeline where hc fw audit runs.

ORG_IDENTIFIER

Organization

The Harness organization the pipeline belongs to.

PROJECT_IDENTIFIER

Project

The Harness project the pipeline belongs to.

Harness CI injects all five variables automatically. If you run hc fw audit outside a Harness CI pipeline (for example, in a local shell or a third-party CI system), set them manually so the firewall report is attributed correctly.

Example: Jenkins declarative pipeline


Package manager variables

These variables configure individual package manager clients to route traffic through Harness.

Go modules

Variable
Description

GOPROXY

Go module proxy URL. Set to your Harness registry Go endpoint to route go get and go mod download through Harness.

Example:

Hugging Face

Variable
Description

HF_ENDPOINT

Overrides the default huggingface.co endpoint. Set to your Harness registry Hugging Face URL.

HF_TOKEN

Hugging Face authentication token. Set to your Harness identity token (from Set Up Client).

HF_HUB_ETAG_TIMEOUT

Seconds before the Hub ETag check times out. Increase for large models on slow connections.

HF_HUB_DOWNLOAD_TIMEOUT

Seconds before a model download times out. Increase for large files.

Example:

Maven plugin

The Harness Maven plugin reads these variables instead of requiring credentials in ~/.m2/settings.xml.

Variable
Description
Required

DEPLOY_REPO_URL

Maven repository URL for mvn deploy.

Yes (deploy)

DEPLOY_USERNAME

Username for deployment.

Yes (deploy)

DEPLOY_TOKEN

Token or password for deployment.

Yes (deploy)

DEPLOY_THREAD_COUNT

Number of threads for parallel artifact upload. Defaults to the number of CPU cores.

No

RESOLVER_REPO_URL

Repository URL for mvn harness:enforce-resolution.

Yes (resolution)

RESOLVER_USERNAME

Username for resolution.

Yes (resolution)

RESOLVER_TOKEN

Token or password for resolution.

Yes (resolution)

Example:

Go to Maven client setup for the full plugin configuration.


Migration variables

These variables are referenced in migration configuration files. They follow standard shell-substitution syntax (${VAR}) when used in YAML migration configs.

Variable
Used in
Description

HARNESS_TOKEN

Migration config YAML

Same as HARNESS_API_KEY; some migration tool examples use this alias.

HARNESS_USER

Migration config YAML

Same as HARNESS_EMAIL; used as the username in migration tool authentication.

SOURCE_PASSWORD

Migration config YAML

The token or password for the source registry (JFrog, ECR, etc.) being migrated from.

Example migration config fragment:

Go to Migrate to Harness Artifacts for step-by-step migration guides.


Terraform provider variables

The Harness Terraform provider reads these TF_VAR_* variables automatically when they correspond to declared input variables in your configuration.

Variable
Maps to
Description

TF_VAR_harness_platform_api_key

harness_platform_api_key input var

API key passed to the provider's platform_api_key argument.

TF_VAR_harness_account_id

harness_account_id input var

Account ID passed to the provider's account_id argument.

TF_VAR_space_ref

space_ref input var

Registry scope reference (account, org, or project path).

Example: provider configuration using env vars

Go to Terraform provider reference for full resource documentation.


Troubleshooting

Commands fail with "unauthorized" even though the token looks correct

Check which variable name the tool expects. Some tools require HARNESS_API_KEY; the hc CLI also accepts HARNESS_API_TOKEN. If both are set, HARNESS_API_TOKEN takes precedence. Run echo $HARNESS_API_KEY and echo $HARNESS_API_TOKEN to confirm one is populated and not accidentally empty.

Also confirm the token has not expired. Go to My Profile > API Keys in the Harness UI to check the token's expiry date.

GOPROXY resolves modules from the public proxy instead of Harness

Go reads GOPROXY as a comma-separated list and tries each proxy in order. If GOPROXY is not set, Go falls back to https://proxy.golang.org. Check the value with go env GOPROXY. To force all resolution through Harness and block the public proxy, set GOPROXY to your Harness endpoint only (no comma-separated fallback). For private modules that should not be sent to the public proxy or checksum database, set GOPRIVATE to your module path prefix. This tells Go to fetch those modules directly and skip checksum validation:

Dependency Firewall shows no pipeline context in the Affected Pipelines view

The pipeline context variables (HARNESS_PIPELINE_ID, HARNESS_BUILD_ID, HARNESS_STAGE_ID, ORG_IDENTIFIER, PROJECT_IDENTIFIER) must be set before hc fw audit runs. In Harness CI, they are injected automatically. In Jenkins, GitHub Actions, or a local shell, set them manually in the step that runs the audit command.

Terraform apply fails with "account_id: required field is missing"

The TF_VAR_* naming convention requires the variable to be declared in your .tf files. If your config uses var.harness_account_id, the matching env var is TF_VAR_harness_account_id. Check for capitalisation mismatches; Terraform variable names are case-sensitive.

Last updated

Was this helpful?