Build artifacts and artifact repositories

Intermediate · 14 min

What a build artifact is, why it needs a version and a digest, how artifact repositories store and proxy packages, and why published versions must never change.

Before thisAnatomy of a pipeline: stages, jobs and gatesTests and quality gates in the pipeline

DevOpsFusion · 14 min

Build artifacts and artifact repositories

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by DevOpsFusionReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • A build artifact is the packaged output of the pipeline, such as a jar, a wheel, a tarball or a container image, and it is the thing you deploy, not the source code.
  • Every artifact needs an identity: a version people can read, the commit it was built from, and a content digest such as sha256 that proves the bytes.
  • Builds are not reproducible by default. Timestamps alone gave two different sha256 digests for the same source, so trust the digest of the file you tested, not a rebuild.
  • An artifact repository stores your published artifacts and proxies public registries, so builds keep working and you control what comes in.
  • Published versions must be immutable. If 1.4.0 can be overwritten, you can no longer know what is running or roll back to what you had.

What the pipeline actually produces

The pipeline takes source code in and, if the gates pass, puts something deployable out. That something is the build artifact: a Java .jar, a Python wheel, a compiled Go binary, a zipped static site, or a container image. Production runs the artifact, not the Git repository.

That distinction sounds pedantic until something goes wrong. A bug report comes in for “version 1.4”. Which source produced it? Which tests ran against it? Is staging running the same thing as production? Without a clear identity for artifacts, nobody can answer, and every investigation starts with guessing.

Identity: version, commit and digest

An artifact needs three labels.

  • A version for humans, like 1.4.0. Semantic versioning gives the numbers meaning.
  • The commit it was built from, so you can read the exact source.
  • A content digest, a cryptographic hash such as sha256 of the file’s bytes. Two files with the same digest are, for practical purposes, the same file.

The digest matters because the other two can lie. A version can be reused by mistake, and a commit can be built twice into different bytes.

Same source, different bytes

That last point surprises people, so I tested it. I put two small files in a directory, packed them with tar -czf, waited a second, touched one file without changing its content, and packed them again:

$ shasum -a 256 a.tgz b.tgz
20acefe00f7ada2fc095ea1921db40d75937f00ea2872a57751c032962733893  a.tgz
d6d487f27a10aaea97d9c4069ec2c5f44e027e939d9428c9e41a89c423e1e70d  b.tgz
$ cmp a.tgz b.tgz
a.tgz b.tgz differ: char 5, line 1

Same content, different digests. Byte 5 is inside the gzip header, where gzip records a modification time. The tar entries also carry the files’ timestamps and owner. Real compilers and packagers add more: build paths, dates, random ordering.

Making a build reproducible, where the same source always gives the same bytes, takes deliberate effort. As a small example, I committed the files to Git and packed them with git archive, which takes file times from the commit rather than the disk, piped through gzip -n, which leaves out the name and time:

$ git -C src archive --format=tar --prefix=shop/ HEAD | gzip -n > c.tgz
$ touch src/shop.py
$ git -C src archive --format=tar --prefix=shop/ HEAD | gzip -n > d.tgz
$ shasum -a 256 c.tgz d.tgz
e08bdbd28dd220fa9ce47b1bfb9a8660d6df6c11be7b26255e0644b53d7eb4c0  c.tgz
e08bdbd28dd220fa9ce47b1bfb9a8660d6df6c11be7b26255e0644b53d7eb4c0  d.tgz

Identical. Most real toolchains need more work than this, and the Reproducible Builds project under deeper tracks how. The practical rule for most teams: don’t rebuild, promote. Test an artifact, record its digest, and deploy those exact bytes. That is the subject of build once, promote through environments.

Artifacts are not caches

CI systems store two kinds of files between runs, and they are easy to confuse.

  • A cache speeds up builds: downloaded dependencies, compiled intermediate files. It can vanish at any time and the build still works, just slower.
  • An artifact is a product. Later stages deploy it, and you may need it months later for a rollback or an audit.

GitHub Actions has separate features for each, covered in caching, artifacts and matrix builds. Note that CI-run artifacts there expire after a retention period. That is fine for passing files between jobs, and wrong for anything you might deploy later.

Artifact repositories

An artifact repository is the long-term store. Products include JFrog Artifactory, Sonatype Nexus, GitHub Packages, GitLab’s package registry and the cloud providers’ own registries. They usually offer three kinds of repository:

  • Local or hosted: your own published artifacts.
  • Remote or proxy: a caching proxy in front of public registries such as npm, PyPI or Maven Central. Builds fetch through it, so they keep working when the public registry is down, you keep copies of packages that get deleted upstream, and you can scan or block what comes in.
  • Virtual or group: one URL that combines the two, so build tools need one address.

They also store metadata alongside each artifact: who published it, from which commit and pipeline run, and scan results. Container images live in the same kind of system, called a registry, covered in registries, tags and image provenance.

Immutability, demonstrated

The most important rule for a repository is that a published version never changes. I wrote a 13-line publish.sh that stores a file under repo/<name>/<version>/, writes its digest and commit to metadata.json, makes the directory read-only, and refuses if the version already exists. Publishing 1.4.0, then trying to publish a changed build under the same number:

$ ./publish.sh c.tgz shop 1.4.0
published shop 1.4.0 sha256:e08bdbd28dd2
$ ./publish.sh e.tgz shop 1.4.0
refused: shop 1.4.0 already published
exit=1
$ cat repo/shop/1.4.0/metadata.json
{"name":"shop","version":"1.4.0","sha256":"e08bdbd28dd220fa9ce47b1bfb9a8660d6df6c11be7b26255e0644b53d7eb4c0","commit":"103a23e"}

Real repositories have a setting for this, usually per repository, and release repositories should have it switched on. If 1.4.0 can be overwritten, a rollback to 1.4.0 might not give you what you had, and the deploy log stops being evidence. The fix for a bad release is always a new version.

About the video

DevOpsFusion’s “Artifacts in DevOps Explained! Why We Use Artifactory (JFrog Tutorial)” (November 2025, about 14 minutes) explains, per its description and chapters, what artifacts are, why repositories matter, what JFrog Artifactory is, its repository types, and how it works, with diagrams aimed at beginners. It is a small channel and leans on one product, but the concepts carry over to Nexus and the cloud registries. It does not appear to cover reproducibility or digests, which this lesson adds. I had no transcript, so this is from the title, description and chapters. English was judged from the same metadata. Harness’s five-minute overview of artifact types is under deeper.

Where this fits

Artifacts are built and stored by a CI server. The last lesson in this group compares the three you are most likely to meet: CI servers compared: Jenkins, GitLab CI and Actions.

Check yourself

  1. 01What is the difference between a CI cache and an artifact?

    A cache holds things that speed up a build, such as downloaded dependencies, and it can be thrown away at any time. An artifact is the product of the build that later stages deploy, and it must be kept, versioned and traceable.

  2. 02You build the same commit twice and the sha256 digests differ. Is something wrong?

    Not necessarily. Most build tools embed timestamps, file ordering or paths, so builds are not reproducible by default. It does mean you should deploy the exact artifact you tested, identified by its digest, rather than rebuilding.

  3. 03Why would a company proxy npm or PyPI through its own artifact repository?

    To cache packages so builds still work if the public registry is slow or down, to keep a copy of versions that get deleted upstream, and to control and scan which third-party packages enter the build.

  4. 04Someone wants to republish version 2.3.1 with a small fix. What should they do instead?

    Publish 2.3.2. A version number must always refer to the same bytes, or every record of what was deployed and every rollback target becomes unreliable.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark