Artifactory Gradle Plugin

Publish Gradle artifacts and build information to JFrog Artifactory.

The Artifactory Gradle Plugin is for Gradle developers who want publishing configured in the build. It collects Gradle publications, deploys their artifacts, and publishes build information to JFrog Artifactory.

📘

Note

Use plugin 6.x for Gradle 9 or later. Its current documented minimum is Gradle 8. Use plugin 5.x for Gradle 6.8.1 through 8. If your CI is already CLI-first, consider jf gradle instead. Do not start new projects on plugin 4.x.

Prerequisites

  • A supported Gradle and JDK pairing. Gradle 9 requires Java 17 or later.
  • A Maven or Gradle local repository in JFrog Artifactory.
  • Deploy and build-info permissions.
  • maven-publish, ivy-publish, or both, plus at least one publication.
  • Credentials stored in gradle.properties or CI secrets, not in the build script.
  • Use the same Gradle build name and number for artifactoryPublish and build-info.

Before You Begin

Confirm a Maven or Gradle local repository, deploy plus publish-build-info permission, and a publication that matches what you deploy. For the model these steps assume, see . To choose between the plugin and jf gradle, see .

Quick Start

This Groovy example creates a Maven publication and sends it to Artifactory.

To publish Gradle artifacts and build information to Artifactory:

plugins {
    id 'java'
    id 'maven-publish'
    id 'com.jfrog.artifactory' version '6.+'
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
}

artifactory {
    publish {
        contextUrl = 'https://acme.jfrog.io/artifactory'
        repository {
            repoKey = 'libs-snapshot-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
        }
        defaults {
            publications('ALL_PUBLICATIONS')
        }
    }
}

Set artifactory_user and artifactory_password in user-level ~/.gradle/gradle.properties or protected CI variables.

Run:

./gradlew artifactoryPublish

The expected task flow is:

artifactoryPublish → extractModuleInfo → artifactoryDeploy
BUILD SUCCESSFUL

artifactoryPublish exists on each project. artifactoryDeploy runs on the root project and deploys artifacts and build-info.

⚠️

Warning

An artifactory block alone is not enough. Apply maven-publish or ivy-publish and define a publication, or Gradle cannot provide a PublishingExtension.

What You Should See Next

  1. Check the task output for deployed artifact URLs and a build-info success message.
  2. In the JFrog Platform UI, open Builds and select the build name and number.
  3. If JFrog CLI is configured, check the build API:
jf rt curl -s -XGET /api/build/<BUILD_NAME>

Where:

  • <BUILD_NAME>: The name of the published build

For example:

jf rt curl -s -XGET /api/build/orders-service

Kotlin DSL

To configure the Artifactory Gradle Plugin in a Kotlin DSL build script, use ArtifactoryPluginConvention:

configure<ArtifactoryPluginConvention> {
    publish {
        contextUrl = "https://acme.jfrog.io/artifactory"
        repository {
            repoKey = "libs-snapshot-local"
            username = project.property("artifactory_user") as String
            password = project.property("artifactory_password") as String
        }
        defaults {
            publications("ALL_PUBLICATIONS")
        }
    }
}

Configuration Reference

Core Publish Settings

The following properties define the deployment target and build-info behavior.

PropertyDefaultPurpose
contextUrl—Artifactory base URL
repository.repoKey—Single deployment repository
repository.releaseRepoKey—Release repository
repository.snapshotRepoKey—Snapshot repository
repository.username—Publisher username
repository.password—Password or access token
publishBuildInfotruePublish build information
forkCount3Parallel deploy workers

Publication Settings

The following properties control which publications the plugin deploys.

PropertyDefaultPurpose
publications(...)known default publicationsSelect publications
publications("ALL_PUBLICATIONS")—Select all known publications
skipfalseSkip a project
publishArtifactstrueDeploy artifacts
publishPomtruePublish POMs
publishIvytruePublish Ivy descriptors
moduleTypeGRADLEModule type in build-info

Valid module types include GENERIC, MAVEN, GRADLE, IVY, DOCKER, NUGET, NPM, GO, PYPI, CPP, and BUILD.

Build Information

artifactory {
    buildInfo {
        setBuildName('orders-service')
        setBuildNumber(System.getenv('BUILD_NUMBER'))
        setProject(System.getenv('JF_PROJECT'))
    }
}

The generated local files are moduleInfo.json and build-info.json. For what a build-info record contains, see .

Multi-Project Builds

Apply the plugin to selected subprojects and skip aggregator projects:

plugins {
    id 'com.jfrog.artifactory' version '6.+' apply false
}

subprojects {
    apply plugin: 'com.jfrog.artifactory'
}

artifactoryPublish.skip = true

Subprojects inherit root Artifactory configuration and can override their own publication settings.

CI Notes

A CI driver can provide settings through a build-info properties file. The plugin checks BUILDINFO_PROPFILE and PROP_PROPS_FILE. When neither is set outside CI, No build-info config properties file path provided. is informational. Normal build-script configuration can still publish.

Examples

Troubleshooting

The following table lists common publish failures and how to resolve them.

ProblemResolution
PublishingExtension does not existApply maven-publish or ivy-publish and define a publication.
Unsupported Gradle versionMatch plugin 6.x with Gradle 8+ or plugin 5.x with 6.8.1–8.
Unsupported class-file major versionUse a JDK supported by the Gradle wrapper. Gradle 9 normally requires Java 17+.
401 or 403Check credentials and deploy or build-info permissions.
No artifactsSelect an existing publication, or use ALL_PUBLICATIONS.
Wrong snapshot or release repositoryConfigure releaseRepoKey and snapshotRepoKey to match versioning.
Build not under a JFrog ProjectSet buildInfo.project to the correct project key.
Informational property-file warningIgnore it outside CI when build-script configuration is complete.

Migration from Plugin 4.x

Move publishBuildInfo into publish, replace publishConfigs() with publications(), and replace old clientConfig.publisher, clientConfig.proxy, and clientConfig.info APIs with the current publish, proxy, and buildInfo blocks.

Related Topics


Did this page help you?