A Jenkins plugin that integrates the Harness CLI (harness) into Jenkins pipelines and Freestyle jobs, enabling you to push artifacts to the Harness Artifact Registry directly from your CI builds.
Upgrading from 1.x: version 2.0 replaces the retired
hcCLI (harness/harness-cli) with the Harness CLI from harness/cli. Command syntax changes (for examplehc 'artifact push generic my-registry app.jar --name app'becomesharness 'push artifact:generic my-registry/app app.jar'), the pipeline stephcis renamedharness, and a pinned tool version must be a harness/cli release such as3.13.0. See Upgrading from 1.x.
- A Harness account (any tier)
- A Harness personal access token (
pat.…), service account token (sat.…) or scoped token (st.…)
- Install the Harness Plugin. Go to Manage Jenkins → Plugins.

- Configure your Harness CLI details. Go to Manage Jenkins → System.

- Configure Harness CLI as a tool in Jenkins. For more information, see Configure Harness CLI as a tool section.
To use Harness CLI in your pipeline jobs, configure it as a tool in Jenkins. Go to Manage Jenkins → Tools.
If your agent has internet access, you can configure the installer to automatically download the Harness CLI from GitHub releases (harness/cli). The installer verifies the download's SHA-256 checksum and registers the bundled Artifact Registry plugin (harness-har) inside the tool directory, so it does not use or modify the agent user's ~/.harness.
-
Go to Manage Jenkins → Tools and then navigate to Harness CLI installations.
-
Click Add Harness CLI. Provide a name (for example,
harness-cli). -
Enable Install automatically, and set the required Version (for example,
3.13.0).The plugin downloads the binary from the harness/cli GitHub releases automatically.
Note: To always install the latest release, leave the version field empty. Jenkins then checks GitHub for the latest release at most once an hour; pin a version to skip the check entirely.
Go to Manage Jenkins → System and then navigate to Harness CLI Configuration.
| Field | Description |
|---|---|
| API URL | Harness API endpoint. For example, https://app.harness.io. |
| API Token | Personal access token, service account token or scoped token - stored as a Jenkins secret. |
| Organization ID | Optional. Your Harness Organization slug. For example, default. |
| Project ID | Optional. Your Harness Project slug. |
Every Harness CLI command run by the plugin receives these values as environment variables (HARNESS_API_KEY, HARNESS_API_URL, HARNESS_ORG, HARNESS_PROJECT). No credentials are written to the agent, so there is no login or logout step, builds on different agents need no extra setup, and concurrent builds on the same agent do not interfere with each other. API tokens are masked in the command line and output written to the build log.
A job can use its own credentials instead of the global ones. For each command, the first match wins:
--profile <name>in the command, orHARNESS_PROFILEset in the build environment: a profile saved earlier withharness auth login.HARNESS_API_KEYset in the build environment. SetHARNESS_API_URL,HARNESS_ORGandHARNESS_PROJECTas needed too; the global values are not mixed in.- The global Harness CLI Configuration.
HARNESS_ORGandHARNESS_PROJECTset in the build environment take precedence over the configured ones.
The recommended way is a Jenkins Secret text credential bound with withCredentials, which Jenkins also masks in the log:
withCredentials([string(credentialsId: 'harness-prod-token', variable: 'HARNESS_API_KEY')]) {
withEnv(['HARNESS_API_URL=https://app.harness.io', 'HARNESS_ORG=default', 'HARNESS_PROJECT=my-project']) {
harness 'push artifact:generic my-registry/app app.jar --version 1.0.0'
}
}
harness auth login --api-url <url> --api-token <token> works in a harness step, but the saved profile is only used by commands that name it, for example harness 'push artifact:generic my-registry/app app.jar --profile default'. Otherwise the global credentials still apply.
With the automatic installer, profiles are saved in a CLI home private to the job's workspace (<workspace>@tmp/harness-cli-home), so other jobs on the agent never see them. They do persist across builds of the same job until you run harness auth logout or the workspace is wiped. Pass the token from a credential rather than writing it in the Jenkinsfile.
-
In a Freestyle job configuration, go to Build Steps → Add build step and then select Run Harness CLI command.
-
Select the CLI installation (or leave as Use harness from system PATH) and type the command to run. You may include or omit the leading
harness. For example:push artifact:rpm my-repo/mypackage /path/to/file.rpm.
pipeline {
agent any
tools {
harnessCli 'harness-cli' // matches the name set in Manage Jenkins → Tools
}
stages {
stage('Build') {
steps {
sh 'mvn clean package -DskipTests'
}
}
stage('Push to Harness Artifact Registry') {
steps {
harness 'push artifact:generic my-registry/myapp target/myapp-1.0.jar --version 1.0.0'
}
}
}
}
pipeline {
agent any
tools { harnessCli 'harness-cli' }
stages {
stage('Push RPM') {
steps {
harness 'push artifact:rpm rpm-repo/mypackage dist/mypackage-1.0.x86_64.rpm'
}
}
stage('Push Debian package') {
steps {
harness 'push artifact:debian debian-repo dist/mypackage_1.0_amd64.deb --distribution bookworm --component main'
}
}
}
}
node {
tool name: 'harness-cli', type: 'io.jenkins.plugins.har.cli.HarnessCliInstallation'
stage('Push') {
harness 'push artifact:generic my-registry/output build/output.zip --version 1.0.0'
}
}
The harness step runs any Harness CLI command, not only pushes. Pass the arguments without the leading harness.
harness step argument |
Description |
|---|---|
version |
Print installed CLI version |
auth status |
Check the credentials and scope in use |
push artifact:generic <registry>/<name> <file> --version <v> |
Push a generic artifact |
push artifact:rpm <registry>/<name> <file.rpm> |
Push an RPM package |
push artifact:debian <registry> <file.deb> --distribution <d> --component <c> |
Push a Debian package |
list artifact <registry> |
List artifacts in a registry |
Note: Run
harness push --helpor see the Harness CLI repository for the full command reference.
Version 2.0 moves the plugin from the retired hc CLI (harness/harness-cli) to the Harness CLI (harness/cli).
- Command syntax: rename
hcsteps toharnessand update their arguments, and update the arguments of Freestyle build steps. For example,artifact push generic my-registry app.jar --name app --version 1.0.0becomespush artifact:generic my-registry/app app.jar --version 1.0.0. Thetools { harnessCli '…' }directive does not change. - Pinned versions: a pinned tool version must be a harness/cli release, for example
3.13.0. The installer only downloads releases from that page, so any other version, such as1.3.47, is rejected. Leave the field empty to install the latest release. Agents reinstall automatically on the next build. - Authentication: the plugin no longer runs
hc auth loginorhc auth logout. Credentials from Manage Jenkins → System are passed to each command as environment variables, unless the job supplies its own (see Per-job credentials). Shell steps that call the CLI directly (for example"$HARNESS_CLI_PATH/harness") do not receive the global credentials, and in Pipeline jobs they cannot run Artifact Registry commands such aspush artifact:.... Use theharnessstep for those.
Refer to CONTRIBUTING.md.
Apache License 2.0. Refer LICENSE.



