jf gradle
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
- 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](-[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.
Configuration Notes
- Run once per project: Configuration persists in
.jfrog/projects/. Re-run when changing repository assignments. - Global vs project: Use
--globalfor all Gradle projects on the machine. Without it, configuration is project-specific. - 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
Gradle build configuration saved successfully.
How to Verify
After running, confirm the configuration exists:
cat .jfrog/projects/gradle.yamlBuild: 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=5Important Notes
- Build-info publishing: Using
--build-nameand--build-numberonly collects build info. Publish withjf rt build-publish <name> <number>. - 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. You can specify them in any of the following ways:
Option 1 — gradle.properties
artifactory.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 (e.g., 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>. |
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.
Quick setup:
- 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 |
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 8 days ago
