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 gradleinstead. 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.propertiesor CI secrets, not in the build script. - Use the same Gradle build name and number for
artifactoryPublishand 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 artifactoryPublishThe expected task flow is:
artifactoryPublish → extractModuleInfo → artifactoryDeploy
BUILD SUCCESSFULartifactoryPublish exists on each project. artifactoryDeploy runs on the root project and deploys artifacts and build-info.
Warning
An
artifactoryblock alone is not enough. Applymaven-publishorivy-publishand define a publication, or Gradle cannot provide aPublishingExtension.
What You Should See Next
- Check the task output for deployed artifact URLs and a build-info success message.
- In the JFrog Platform UI, open Builds and select the build name and number.
- 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-serviceKotlin 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.
| Property | Default | Purpose |
|---|---|---|
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 |
publishBuildInfo | true | Publish build information |
forkCount | 3 | Parallel deploy workers |
Publication Settings
The following properties control which publications the plugin deploys.
| Property | Default | Purpose |
|---|---|---|
publications(...) | known default publications | Select publications |
publications("ALL_PUBLICATIONS") | — | Select all known publications |
skip | false | Skip a project |
publishArtifacts | true | Deploy artifacts |
publishPom | true | Publish POMs |
publishIvy | true | Publish Ivy descriptors |
moduleType | GRADLE | Module 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 = trueSubprojects 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.
| Problem | Resolution |
|---|---|
PublishingExtension does not exist | Apply maven-publish or ivy-publish and define a publication. |
| Unsupported Gradle version | Match plugin 6.x with Gradle 8+ or plugin 5.x with 6.8.1–8. |
| Unsupported class-file major version | Use a JDK supported by the Gradle wrapper. Gradle 9 normally requires Java 17+. |
| 401 or 403 | Check credentials and deploy or build-info permissions. |
| No artifacts | Select an existing publication, or use ALL_PUBLICATIONS. |
| Wrong snapshot or release repository | Configure releaseRepoKey and snapshotRepoKey to match versioning. |
| Build not under a JFrog Project | Set buildInfo.project to the correct project key. |
| Informational property-file warning | Ignore 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
Updated about 1 month ago
