Use Gradle with JFrog CLI
Run Gradle builds with Artifactory integration for dependency resolution and build information collection.
This topic covers the following tasks:
When to Use
Use jf gradle if your Java/Kotlin project uses Gradle (build.gradle or build.gradle.kts) for builds and you want dependencies resolved from Artifactory with build-info collection. For Maven-based projects, use jf mvn.
Prerequisites
- Gradle 6.0+ installed and available on
$PATH(verify withgradle --versionor./gradlew --version). On macOS:brew install gradle. On Linux: see gradle.org/install. - Java Development Kit (JDK) 11+ installed (verify with
java -version). On macOS:brew install openjdk. On Linux: install via your package manager or Adoptium. - Run
jf gradle-configin the project directory before the first build. - Configure a server with
jf config addorjf c add. - Authentication to Artifactory is required.
Configuration: jf gradle-config
jf gradle-configGenerate Gradle build configuration for resolving and deploying artifacts through Artifactory. Run this once per project before your first build.
To configure Gradle for Artifactory:
Synopsis
jf gradle-config [options]
Aliases: gradlec
Configuration Options
| Flag | Default | Description |
|---|---|---|
--global | false | Apply configuration globally for all projects |
--server-id-resolve | — | Artifactory server ID for dependency resolution |
--server-id-deploy | — | Artifactory server ID for deployment |
--repo-resolve | — | Repository for resolving dependencies |
--repo-deploy | — | Repository for deploying artifacts |
--uses-plugin | false | Set to true if the Gradle Artifactory Plugin is already applied |
--use-wrapper | false | Use the Gradle wrapper |
--deploy-maven-desc | true | Deploy Maven descriptors |
--deploy-ivy-desc | true | Deploy Ivy descriptors |
--ivy-desc-pattern | [organization]/[module]/ivy-[revision].xml | Deployment pattern for Ivy descriptors |
--ivy-artifacts-pattern | [organization]/[module]/[revision]/[artifact]-[revision](/docs/-[classifier]).[ext] | Deployment pattern for Ivy artifacts |
Configuration Examples
View Help
jf gradle-config --helpNon-Interactive Configuration
Configure Gradle with non-interactive flags:
jf gradle-config --server-id-resolve=<server-id> --repo-resolve=<repo-name> --server-id-deploy=<server-id> --repo-deploy=<repo-name>Where:
- <server-id>: The server ID configured using
jf config add - <repo-name>: The name of the repository in Artifactory
For example:
jf gradle-config --server-id-resolve=my-server --repo-resolve=gradle-virtual --server-id-deploy=my-server --repo-deploy=gradle-localWhy Run Config First?
You must run jf gradle-config before jf gradle. The config command creates a .jfrog/projects/gradle.yaml file that tells the CLI which Artifactory repositories to resolve from and deploy to. Without it, jf gradle cannot integrate with Artifactory.
If you skip this step, you will see the error: no config file was found! Before running the 'jf gradle' command on a project for the first time, the project should be configured with the 'jf gradle-config' command.
Shortcut
: In CI/CD, pass all flags non-interactively so the config step is fully automated and reproducible.
Note
: Running
jf gradle-configwithout flags in a non-TTY environment (CI/CD pipelines, piped shell commands) will cause the CLI to crash with a runtime panic (panic: device not configured). Always pass all required flags non-interactively in automated environments.
Configuration Notes
- Run once per project: Configuration persists in
.jfrog/projects/. Re-run when changing repository assignments. Run this command from the root of your Gradle project (the directory containingbuild.gradleorbuild.gradle.kts) — the CLI does not validate that a Gradle project exists and will create the config in any directory. - Global vs project: Use
--globalfor all Gradle projects on the machine. Without it, configuration is project-specific. The global config is stored at~/.jfrog/projects/gradle.yaml(macOS/Linux) or%USERPROFILE%\.jfrog\projects\gradle.yaml(Windows). - Artifactory Plugin: If your
build.gradlealready applies the Gradle Artifactory Plugin, set--uses-plugin=trueto avoid conflicts. - Wrapper support: Use
--use-wrapper=trueif your project uses the Gradle wrapper (gradlew). - Ivy descriptors: The
--deploy-ivy-descand--ivy-desc-patternflags control Ivy descriptor deployment. Most modern projects use Maven descriptors (--deploy-maven-desc).
Expected Output
$ jf gradle-config --server-id-resolve=my-server --repo-resolve=gradle-virtual --server-id-deploy=my-server --repo-deploy=gradle-local
[Info] gradle build config successfully created.
How to Verify
After running, confirm the configuration exists:
cat .jfrog/projects/gradle.yamlA correctly generated file looks like this:
version: 1
type: gradle
resolver:
repo: gradle-virtual
serverId: my-server
deployer:
repo: gradle-local
serverId: my-server
deployMavenDescriptors: true
deployIvyDescriptors: true
ivyPattern: '[organization]/[module]/ivy-[revision].xml'
artifactPattern: '[organization]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]'Build: jf gradle
jf gradleRun Gradle build with Artifactory integration for dependency resolution and build information collection.
To run a Gradle build with Artifactory integration:
Synopsis
jf gradle <tasks-and-options> [options]
Aliases: none
Arguments
| Argument | Required | Description |
|---|---|---|
tasks-and-options | Yes | Gradle tasks and options (for example, build, -b path/to/build.gradle) |
Build Options
| Flag | Default | Description |
|---|---|---|
--build-name | — | Build name for build information (requires --build-number) |
--build-number | — | Build number for build information (requires --build-name) |
--project | — | JFrog Artifactory project key |
--module | — | Optional module name for build information |
--detailed-summary | false | Include affected files in the command summary |
--threads | 3 | Number of threads for uploading build artifacts |
--server-id | — | Server ID configured with jf config add |
--scan | false | Scan all files with Xray on the local file system before upload; skip upload if vulnerabilities are found |
--format | table | Output format for the --scan option. Accepts table, json, simple-json, or sarif |
Build Examples
Build and Publish Build Information
jf gradle build --build-name=<build-name> --build-number=<build-number>Where:
- <build-name>: A name for the build (for example,
my-java-app) - <build-number>: A number or identifier for the build run (for example,
1)
For example:
jf gradle build --build-name=my-java-app --build-number=1Build with Custom Threads
jf gradle clean build --build-name=my-app --build-number=1 --threads=5Expected Output
A successful build prints the Gradle task output followed by a summary of uploaded artifacts:
[Info] Running gradle...
...
BUILD SUCCESSFUL in Xs
[Info] Deploying artifact: https://<server>/artifactory/<repo>/<path>/<artifact>.jar
[Info] Deploying artifact: https://<server>/artifactory/<repo>/<path>/<artifact>.pom
[Info] Build info successfully collected. To publish the build info to Artifactory, run:
jf rt build-publish <build-name> <build-number>
If no artifacts were deployed, see Selecting Publications for Gradle.
Important Notes
- Build-info publishing: Using
--build-nameand--build-numberonly collects build info. Publish withjf rt build-publish <name> <number>(jf rtis the legacy Artifactory namespace; the command works in all current CLI versions). - Gradle tasks: All standard Gradle tasks and flags work (
clean,build,test,-x,-b, and others). - Artifactory Plugin: If your
build.gradlealready applies the Gradle Artifactory Plugin, set--uses-plugininjf gradle-configto avoid conflicts. - Hidden flag —
--module: The--moduleflag is functional and collected by the build-info framework, but does not appear injf gradle --helpoutput. It works when passed on the command line alongside--build-nameand--build-number.
Selecting Publications for Gradle
If you run jf gradle clean artifactoryPublish and the build succeeds but no artifacts are deployed, the Artifactory Gradle plugin likely does not know which publication(s) to publish.
To specify publications for the Artifactory Gradle plugin:
-
Option 1 —
gradle.propertiesartifactory.publish.publications=release # Or multiple: # artifactory.publish.publications=release,debug -
Option 2 — Command line project property
jf gradle clean artifactoryPublish \ -Partifactory.publish.publications=release \ --build-name="MyApplicationAndroidBuild" \ --build-number="1" \ --project="test" -
Option 3 — In your build script
// build.gradle.kts extra["artifactory.publish.publications"] = "release" // build.gradle (Groovy) // ext["artifactory.publish.publications"] = "release"
These options work because jf gradle passes flags/properties through to the Gradle client, and the Artifactory Gradle plugin's artifactoryPublish task publishes the specified publication(s).
Verify that the publication (for example, release) actually exists in your Gradle publishing block and that your Android/Gradle setup creates a Maven Publication for it.
Native Mode
Gradle supports Native Mode, which bypasses jf gradle-config and all .jfrog/ YAML configuration. In this mode, no Artifactory Gradle plugin is injected — you must configure Gradle to resolve from Artifactory manually. Pass --server-id to specify the server. Build-info is still collected when --build-name and --build-number are provided.
Enable with: export JFROG_RUN_NATIVE=true
For full setup instructions, per-tool comparison, and when to use each mode, see Native Mode.
Platform Notes
- Windows: The Gradle init script is written to
%USERPROFILE%\.gradle\init.d\. IfJAVA_HOMEis set, the script uses Java'suser.homeproperty, which may differ from%USERPROFILE%. - Gradle wrapper: On Unix, ensure
gradlewhas execute permissions (chmod +x gradlew). On Windows, usegradlew.batautomatically.
Environment Variables
| Variable | Default | Description |
|---|---|---|
JFROG_CLI_RELEASES_REPO | — | Configured Artifactory repository name from which to download the JAR needed by the gradle command. Format: <server ID>/<repo name>. The repository should proxy https://releases.jfrog.io. |
JFROG_CLI_DEPENDENCIES_DIR | $JFROG_CLI_HOME_DIR/dependencies | Directory to which JFrog CLI's internal dependencies are downloaded. |
JFROG_CLI_EXTRACTORS_REMOTE | — | Alternative to JFROG_CLI_RELEASES_REPO for offline environments. Format: <server ID>/<repo name>. Note: this variable does not appear in jf gradle --help output but is fully functional. |
Downloading the Maven and Gradle Extractor JARs
For integration with Maven and Gradle, JFrog CLI uses build-info-extractor JAR files. These JARs are downloaded by JFrog CLI from JFrog's distribution (releases.jfrog.io) the first time they are needed.
Air-gapped or offline? See Air-Gapped and Offline Setup for a step-by-step guide.
To download extractors through an Artifactory remote repository:
- Create a remote Maven repository in Artifactory and name it
extractors. Configure it to proxyhttps://releases.jfrog.io/artifactory/oss-release-local. - Verify that this Artifactory server is configured in JFrog CLI using
jf c show. - Set the
JFROG_CLI_EXTRACTORS_REMOTEenvironment variable. The value should be the Server ID followed by a slash and the repository name. For example:my-rt-server/extractors.
CI/CD Example (GitHub Actions)
# .github/workflows/build.yml
steps:
- uses: actions/checkout@v4
- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@v4
env:
JF_URL: ${{ vars.JF_URL }}
JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
- name: Configure Gradle
run: jf gradle-config --server-id-resolve=setup-jfrog-cli-server --repo-resolve=gradle-virtual --server-id-deploy=setup-jfrog-cli-server --repo-deploy=gradle-local
- name: Build with Gradle
run: jf gradle clean build --build-name=my-java-app --build-number=${{ github.run_number }}
- name: Publish build info
run: jf rt build-publish my-java-app ${{ github.run_number }}Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
no config file was found | jf gradle-config was not run | Run jf gradle-config in the project directory |
| 404 on dependency resolution | Resolution repository does not exist or name is wrong | Verify --repo-resolve matches an existing Artifactory repository |
| 401 / 403 errors | Invalid credentials or insufficient permissions | Re-run jf config add with a valid access token |
| Build succeeds but no artifacts deployed | Artifactory Gradle plugin does not know which publication(s) to publish | Set artifactory.publish.publications=release in gradle.properties or via -P flag |
| Conflict with existing Artifactory Gradle plugin | Plugin applied twice | Set --uses-plugin=true in jf gradle-config |
| Extractor JAR download fails | No internet access on build machine | Set JFROG_CLI_EXTRACTORS_REMOTE to an Artifactory remote repo proxying releases.jfrog.io |
| Gradle wrapper not used | Wrapper not enabled in config | Set --use-wrapper=true in jf gradle-config |
[Warn] couldn't extract payload from Access Token (appears twice per run) | Server uses a reference (non-JWT) access token | Informational only — the build proceeds normally. The warning printing twice per invocation is expected behavior. If basic auth is required, add a username via jf config edit |
Enable debug logging: export JFROG_CLI_LOG_LEVEL=DEBUG
Related Topics
- Build Tools Overview — Capabilities matrix and tool reference
- Native Mode — Supported packages with Native Mode
Updated about 1 month ago
