In simple words
- Local repository: stores artifacts your own team builds and uploads.
- Remote repository: a caching proxy for a public source, such as Maven Central or Docker Hub.
- Virtual repository: one address that combines several local and remote repositories, so tools need only one URL.
- Package type: the format a repository holds: Maven, Docker, npm, PyPI, Helm and more.
Big picture
Artifactory has three main kinds of repository, and they work together like a library:
- Local is your own shelf, where you put your books.
- Remote is a borrowing desk. It fetches a book from another library the first time, then keeps a copy.
- Virtual is the one catalogue that searches both, so readers need only one address.
The types
| Type | What it holds | Example name |
|---|---|---|
| Local | Files you publish yourself | libs-release-local |
| Remote | A cached copy of another site, such as Maven Central or Docker Hub | maven-central-remote |
| Virtual | A combined address in front of local and remote repos | libs-virtual |
| Federated | A local repo that stays in sync across sites (lesson 15) | libs-release-fed |
Why use a virtual repository?
Your tools talk to one address, and you can change what sits behind it without touching any project. You could add a second remote repository tomorrow, and no pom.xml or package.json would need to change.
Developer's Maven --> libs-virtual --> 1. libs-release-local (your code) --> 2. libs-snapshot-local (your code) --> 3. maven-central-remote (cached public libs)When a tool asks for a file, the virtual repository checks its members in order and returns the first match. Put your own local repositories first, so your own names always win (this also helps with the dependency confusion problem in lesson 6).
A virtual repository has one more setting: the default deployment repository. When someone uploads to the virtual address, the file goes to that local repository.
How a remote repository works
- A tool asks for
commons-lang3-3.14.0.jar. - The remote repository does not have it, so it downloads it from Maven Central.
- It saves a copy and gives the file to the tool.
- The next request is answered from the copy.
Useful remote settings:
| Setting | What it does |
|---|---|
| URL | the site to copy from, for example https://repo1.maven.org/maven2 |
| Metadata retrieval cache period | how long a "latest version" answer is trusted |
| Store artifacts locally | keep copies (the default). Turn off only for special cases |
| Offline mode | serve only what is already cached |
| Include / exclude patterns | limit which names the remote may fetch |
Make repositories from the command line
You can click in the web page, or use the REST API. The API is better for repeatable setups.
curl -u admin:TOKEN -X PUT -H "Content-Type: application/json" \ https://repo.example.com/artifactory/api/repositories/libs-release-local \ -d '{"key":"libs-release-local","rclass":"local","packageType":"maven"}'Successfully created repository 'libs-release-local'rclass is the repository class: local, remote, virtual or federated. List what exists:
curl -s -u admin:TOKEN https://repo.example.com/artifactory/api/repositories[ { "key" : "libs-release-local", "type" : "LOCAL", "packageType" : "Maven" }, { "key" : "maven-central-remote", "type" : "REMOTE", "packageType" : "Maven" }, { "key" : "libs-virtual", "type" : "VIRTUAL", "packageType" : "Maven" } ]Naming that scales
A clear pattern is <what>-<stage>-<type>:
| Name | Meaning |
|---|---|
docker-dev-local | images from development |
docker-prod-local | images approved for production |
docker-virtual | the one address everyone uses |
Keep dev and prod in separate repositories. Promotion moves files between them (lesson 9).
Package types and layouts
Each repository holds one package type: Maven, Gradle, npm, PyPI, Docker, Helm, NuGet, Go, generic and more. Choose it when you create the repository. It cannot be changed later.
A layout sets the folder structure inside a repository. Maven uses group/artifact/version/file. You rarely change layouts. Just choose the one that matches the package type.
The generic type holds any file. Use it for zip files, installers and scripts.
Common mistakes
- Putting dev and prod builds in one repository.
- Pointing tools directly at a local or remote repository instead of the virtual one.
- Choosing the wrong package type, then having to recreate the repository.
- Putting a remote repository before your local one in the virtual list.
Summary
- Local stores your files, remote caches other sites, virtual combines them in order.
- Teams use one virtual address, and keep dev and prod apart.
- Create repositories with the REST API so setups are repeatable.
- Use clear names so everyone knows what is where.
CHECK YOUR UNDERSTANDING
3 quick questions
1. What does a virtual repository do?
2. Which repository type caches Maven Central?
3. Why keep dev and prod files in separate repositories?
You've finished the free preview of JFrog Artifactory & Nexus
Upgrade to Pro to unlock the remaining 14 lessons, every practice lab and a certificate when you finish.
See plans