Skip to content
$ lynuxpro
← JFrog Artifactory & Nexus

LESSON 2 OF 16 · BEGINNER · 12 MIN

Repository types

Free previewLesson 2 of the 2 free lessons in this Pro course.Unlock all 16

HOW IT WORKSLocal, remote and virtual

requestMaven / Dockerone addressVirtuallibs-virtualLocalyour filesRemotecache of Maven CentralMaven Central
1/5

Developers use one address: the virtual repository.

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

TypeWhat it holdsExample name
LocalFiles you publish yourselflibs-release-local
RemoteA cached copy of another site, such as Maven Central or Docker Hubmaven-central-remote
VirtualA combined address in front of local and remote reposlibs-virtual
FederatedA 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)
OUTPUTterminalutf-8 · 3L

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

  1. A tool asks for commons-lang3-3.14.0.jar.
  2. The remote repository does not have it, so it downloads it from Maven Central.
  3. It saves a copy and gives the file to the tool.
  4. The next request is answered from the copy.

Useful remote settings:

SettingWhat it does
URLthe site to copy from, for example https://repo1.maven.org/maven2
Metadata retrieval cache periodhow long a "latest version" answer is trusted
Store artifacts locallykeep copies (the default). Turn off only for special cases
Offline modeserve only what is already cached
Include / exclude patternslimit 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"}'
SHELLbashutf-8 · 3L
Successfully created repository 'libs-release-local'
OUTPUTterminalutf-8 · 1L

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
SHELLbashutf-8 · 1L
[ { "key" : "libs-release-local", "type" : "LOCAL", "packageType" : "Maven" },  { "key" : "maven-central-remote", "type" : "REMOTE", "packageType" : "Maven" },  { "key" : "libs-virtual", "type" : "VIRTUAL", "packageType" : "Maven" } ]
OUTPUTterminalutf-8 · 3L

Naming that scales

A clear pattern is <what>-<stage>-<type>:

NameMeaning
docker-dev-localimages from development
docker-prod-localimages approved for production
docker-virtualthe 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. 1. What does a virtual repository do?

  2. 2. Which repository type caches Maven Central?

  3. 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