2 min to read
JFrog CLI for Maven & Docker: One Tool to Rule the Artifacts
If we’ve worked with both Maven and Docker in a CI/CD pipeline, we probably know the pain of managing two completely different artifact publishing flows.
Enter JFrog CLI—a unified command-line tool that simplifies working with JFrog Artifactory, no matter the technology. Whether you’re dealing with Java packages or Docker images, JFrog CLI acts as one interface to rule them all.
🧰 What Is JFrog CLI?
JFrog CLI is a smart, lightweight tool that wraps Artifactory’s REST API into a developer-friendly experience. It supports artifact uploads/downloads, builds, Docker operations, and more.
Instead of writing long curl
commands or juggling plugin configurations, we get a consistent, scriptable interface.
🛠️ Use Case 1: Maven Build with JFrog CLI
🔗 Prerequisites
- Artifactory configured with
libs-release
andlibs-snapshot
repositories - JFrog CLI installed and configured
curl -fL https://getcli.jfrog.io | sh
./jfrog rt config <artifactory-server-id> \
--url=https://our-artifactory-url \
--user=<username> \
--password=<password>
🔧 Sample configuration.yml
version: 1
type: maven
resolver:
snapshotRepo: libs-snapshot
releaseRepo: libs-release
serverID: <artifactory-server-id>
deployer:
snapshotRepo: libs-snapshot-local
releaseRepo: libs-release-local
serverID: <artifactory-server-id>
🚀 Build & Publish Maven Project
./jfrog rt mvn "clean install" configuration.yml \
--build-name=maven-demo \
--build-number=1
./jfrog rt build-publish maven-demo 1
🐳 Use Case 2: Docker with JFrog CLI
🔧 Build & Push Docker Image
docker build -t our-artifactory-domain.com/docker-local/hello-world:1.0 .
./jfrog rt docker-login
./jfrog rt docker-push our-artifactory-domain.com/docker-local/hello-world:1.0 \
docker-local \
--build-name=docker-demo \
--build-number=1
./jfrog rt build-publish docker-demo 1
This automatically tracks the image layers, environment variables, and Docker metadata.
🧩 Bonus: Combine Maven + Docker into One Build
You can associate multiple build steps under the same build-name and build-number.
./jfrog rt build-collect-env unified-demo 1
./jfrog rt build-add-git unified-demo 1
./jfrog rt build-publish unified-demo 1
This way, our entire build footprint (Java, Docker, Git commit, env vars) is stored in one place—versioned and auditable.
✅ Why It Matters
Consistency: One CLI for all our artifact types
Traceability: Build info includes environment, VCS, artifacts, dependencies
Simplicity: Easy to script and integrate into CI/CD
Security: Credentials stored and reused securely
🔗 Example Projects
- 📦 Maven + JFrog CLI Sample
- 🐳 Docker example repo coming soon
Comments