For the complete documentation index, see llms.txt. This page is also available as Markdown.

Gradle Plugin

spinner

The Harness Gradle Plugin hooks your existing ./gradlew publish flow: it intercepts the standard publish task, uploads artifacts to Harness Artifact Registry in parallel for faster deployment, and reads registry URL and credentials from environment variables (configured in Configuration) so secrets stay out of source control.

Installation

Add the plugin to your project's build file. Use the Groovy snippets if your scripts are build.gradle, and the Kotlin snippets if they are build.gradle.kts; use the same style in the root build and in subprojects.

For Groovy DSL (build.gradle)

plugins {
    id 'io.harness.gradle' version '1.0.0'
}

For Kotlin DSL (build.gradle.kts)

plugins {
    id("io.harness.gradle") version "1.0.0"
}

Apply to All Subprojects

If you want to apply the plugin to all subprojects, add this to your root build file:

Groovy DSL:

allprojects {
    apply plugin: 'io.harness.gradle'
}

Kotlin DSL:

Configuration

The plugin uses environment variables for configuration. Set these variables before running Gradle commands.

Plugin Settings

Add the harnesspublish configuration block to your build file:

Groovy DSL (build.gradle):

Kotlin DSL (build.gradle.kts):

Environment Variables

Set the required environment variables before running the publish command. You can get these values from the Harness UI Set Up Client section.

Linux/macOS:

Windows (Command Prompt):

Windows (PowerShell):

Configuration Reference

Environment Variable
Description
Required

DEPLOY_REPO_URL

Repository URL for deployment

Yes

DEPLOY_USERNAME

Username for deployment

Yes

DEPLOY_TOKEN

Token/password for deployment

Yes

DEPLOY_THREAD_COUNT

Number of threads for parallel deployment

No

Usage

Deploy Artifacts

Deploy your Gradle project artifacts to Harness Artifact Registry:

The plugin will:

  1. Intercept the standard publish task

  2. Upload artifacts to the configured Harness registry

  3. Use parallel threads for faster deployment (configurable via DEPLOY_THREAD_COUNT)

Configure Deployment Thread Count (Optional)

You can control the number of parallel threads used for deployment:

Example Workflow

Here's a complete example of using the Harness Gradle Plugin in a CI/CD pipeline:

Groovy DSL (build.gradle):

CI/CD Script:

Last updated

Was this helpful?