Skip to content
$ lynuxpro
← JFrog Artifactory & Nexus

LESSON 1 OF 16 · BEGINNER · 12 MIN

Why artifact repositories

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

HOW IT WORKSBuild once, deploy many

CI buildRepositoryshop-api-1.4.2.jarDevStagingProdInternetunreliable
1/5

Without a repository, every build downloads from the internet and every server builds its own copy.

In simple words

  • Artifact: a file produced by a build, such as a .jar, a Docker image, an npm package or a Helm chart.
  • Artifact repository: a server that stores and serves artifacts with versions, permissions and history.
  • Build once, deploy many: build an artifact once, then deploy that exact file to every environment.
  • Artifactory / Nexus: the two most popular artifact repository products.

Big picture

Think of a warehouse. A factory builds products, and the warehouse stores them with labels, so any shop can collect exactly the product it ordered. An artifact repository is that warehouse for software. CI builds your app, and the repository keeps the result, safe and labelled, until someone needs it.

What is an artifact?

An artifact is any file your build produces or your build needs.

KindExamples
Packages.jar, .war, .whl, .tgz, .nupkg
Container imagesshop-api:1.4.2
Charts and installersHelm charts, .deb, .rpm, .zip
Libraries you downloadSpring, React, requests

Two directions matter. Your build produces artifacts (it publishes them). Your build also consumes artifacts (it downloads libraries). A repository helps with both.

The problem without a repository

  • Builds download libraries from the public internet every time. If the site is down, your build breaks.
  • A library author can delete or change a package. Your old build then cannot be repeated.
  • Each server builds its own copy, so "the same version" is not really the same.
  • Nobody knows which code made the file now running in production.
  • Old files pile up on shared disks, or in someone's home folder.

Here is a real example. In 2016 a developer removed a tiny public package called left-pad. Thousands of builds around the world failed in minutes. A repository that had cached the package would have kept working.

Build once, deploy many

The golden rule: build the artifact one time, then move that exact file through dev, test and prod. Never rebuild for production, because a rebuild can give a different result (a new library version, a different compiler, a changed clock).

commit -> CI build -> shop-api-1.4.2.jar in Artifactory                          |-> deploy to dev                          |-> deploy to staging   (same file)                          |-> deploy to prod      (same file)
OUTPUTterminalutf-8 · 4L

You can prove the files are the same by comparing their checksum, a short fingerprint of the content:

sha256sum shop-api-1.4.2.jar
SHELLbashutf-8 · 1L
9b1f4c0e7d2a...c3  shop-api-1.4.2.jar
OUTPUTterminalutf-8 · 1L

If the fingerprint is the same in dev and prod, the file is the same. Artifactory stores this checksum for every file.

Versions: the rules

RuleWhy
Every build gets a version numberyou can say exactly what runs
A released version never changescaches, rollbacks and audits stay correct
A fix is a new version (1.4.3)history stays clear
Use semantic versions: MAJOR.MINOR.PATCHthe number tells you how big the change is

Semantic versioning in one line: change PATCH for a bug fix, MINOR for a new feature that does not break anything, and MAJOR for a change that can break users.

What a repository gives you

BenefitIn plain words
One homeAll packages and images in one place
VersionsEvery build has a number, and nothing is overwritten
CachePublic libraries are copied once, then served fast and offline
Access controlYou choose who can read and who can publish
ScanningCheck files for known security problems
TraceabilityLink a file back to the commit and build that made it
PromotionMove a tested file from dev to prod with a clear record

The main products

ProductNotes
JFrog ArtifactoryMany package types, strong security tools, popular in large companies
Sonatype Nexus RepositoryMany package types, has a free community edition
Cloud registriesECR, GitHub Packages, GitLab Package Registry: simple, tied to one platform

This course teaches Artifactory in depth and Nexus in lesson 13.

How the course fits together

LessonsYou learn
1-3what a repository is, the repository types, how to set one up
4-7publishing and downloading Maven, Docker, npm, PyPI, Helm, and the JFrog CLI
8-10people and tokens, CI and promotion, properties and search
11-12clean-up and security scanning
13-16Nexus, high availability, replication, performance

Common mistakes

  • Rebuilding the same version for each environment.
  • Overwriting a released version. Once 1.4.2 is out, never change it.
  • Letting builds pull straight from the internet.
  • Keeping the only copy of a release on a build server's disk.

Summary

  • An artifact repository stores build results and downloaded libraries.
  • Build once, then promote the same file. Compare checksums to prove it.
  • Released versions never change. A fix gets a new version.
  • You gain speed, safety and a clear history.

CHECK YOUR UNDERSTANDING

3 quick questions

  1. 1. What does 'build once, deploy many' mean?

  2. 2. A release version 1.4.2 has a bug. What should you do?

  3. 3. Which is a benefit of caching public libraries in a repository?