Artifact Repository Integration in Jenkins
A complete, plain-English guide to connecting Jenkins with a repository for your build outputs: how to publish, fetch, version, and promote artifacts safely, so every release is traceable, repeatable, and easy to roll back.
Imagine a bakery that sells bread to many shops. Each morning, the bakers make loaves. If a shop phoned at noon and said, “Last Tuesday’s bread was wonderful, please send the same again,” the bakery would have a problem if it kept nothing but crumbs on the kitchen table. A well-run bakery instead labels each batch, stores it in a numbered rack in a cool room, and hands out loaves from the rack. Anyone can ask for “batch 214” and get exactly that batch, unchanged.
Software builds have the same need. Jenkins turns source code into finished files: packages, libraries, installers, and container images. Those files are called artifacts. If the only copy of an artifact lives in a temporary folder on a build machine, it can vanish, be overwritten, or be rebuilt slightly differently next time. An artifact repository is the numbered rack in the cool room. It stores every artifact with a version, keeps it safe, and serves it to anyone who needs it. This guide explains how Jenkins and an artifact repository work together, from zero, and how to set them up so that releases are reliable and reversible.
1What Is Artifact Repository Integration?
We start with the simplest picture: what an artifact is, what a repository does, and what it means to connect the two to Jenkins.
Jenkins is a tool that automates building, testing, and delivering software. A typical pipeline fetches code, compiles it, runs tests, and produces output. That output is an artifact. Examples include a Java library packaged as a JAR file, a web application packaged as a WAR file, a Python wheel, a Node.js package, a Windows installer, a Helm chart, and a container image.
An artifact repository is a server that stores artifacts and dependencies, gives each one a name and version, and lets other systems upload and download them over the network. Well-known products in this space include JFrog Artifactory, Sonatype Nexus Repository, and the package registries offered by cloud and code-hosting platforms. Integration means teaching your Jenkins pipelines to talk to that repository: to publish what they build, to fetch what they depend on, and to record which build made which artifact.
Think of a public library. Books are written by authors (developers), printed by a publisher (Jenkins), and placed on numbered shelves in the library (the repository). A reader (another build, or a deployment) asks the librarian for a book by title and edition and gets exactly that copy. Nobody borrows books straight from the printing press floor.
flowchart LR
A["Developer pushes code"] --> B["Jenkins builds and tests"]
B --> C["Publish to the artifact repository"]
C --> D["Deploy to test from the repository"]
D --> E["Promote to the release repository"]
E --> F["Deploy to production from the repository"]
Four jobs the integration does
Publish
Upload the finished artifact with a clear name and version at the end of a successful build.
Resolve
Download the libraries and packages your build needs, through the repository, instead of directly from the internet.
Promote
Move a tested artifact from a staging area to a release area, without rebuilding it.
Trace
Record which Jenkins build, which commit, and which dependencies produced each artifact.
This guide uses product-neutral words wherever it can. Individual products use different names for similar ideas, and their screens and features change over time. Always check the current documentation of the product you use.
2Why Artifact Repositories Exist
To see why this integration matters, imagine delivering software without it, and follow what goes wrong.
The problem: the workspace is a temporary place
When Jenkins builds something, it works in a workspace, a folder on a build machine. Workspaces are cleaned, reused, and sometimes destroyed entirely, especially when agents are containers. If a team deploys by copying a file straight from a workspace to a server, several things can go wrong. The file may be overwritten by the next build a minute later. The machine may be gone by tomorrow. Nobody can tell which commit produced the file now running in production. And if the release fails, there is no old copy to put back.
The problem: rebuilding is not the same as re-running
Some teams rebuild the software at each stage: once for testing, again for staging, and again for production. But two builds of the same source code are not always identical. A dependency may have been updated between builds. A compiler may behave differently on another machine. The thing that was tested is then not the thing that ships. The safe rule is build once, deploy many: build a single artifact, store it, and deploy those same bytes to every environment.
The answer: a proper home for outputs
An artifact repository gives every build output a durable, versioned home with access control and a history. It also gives your builds a controlled source for dependencies, which speeds them up and makes them more reliable. Repository managers grew out of the Java world in the mid-2000s, where teams needed a shared place for Maven packages, and have since grown to serve almost every language and container format.
A car factory does not build a fresh prototype for each stage of testing. It builds one car, puts it through crash tests and road tests, and then ships that same design in numbered batches. If a problem appears, the batch number tells the factory exactly which cars to recall. An artifact repository is the batch log and the warehouse in one.
3Words You Need First
A handful of terms come up in every repository discussion. Learn them once here.
Artifact
A file produced by a build, such as a package, an installer, or a container image.
Dependency
An artifact that your project needs in order to build or run, such as a library made by someone else.
Version
A label that tells releases apart, such as 2.4.1. A good version is never reused for different contents.
Coordinates
The full address of an artifact: usually a group or namespace, a name, and a version, plus a format-specific detail.
Package format
The type of package a repository understands, such as Maven, npm, PyPI, NuGet, Docker images, or Helm charts.
Checksum
A short fingerprint of a file’s contents, used to prove that a file has not changed or been corrupted.
A few Jenkins words too
The controller is the main Jenkins server that plans the work. An agent is a worker machine or container that runs the commands. A pipeline is the ordered list of stages in a Jenkinsfile. A credential is a secret stored in Jenkins, such as the token that lets a pipeline upload to the repository. The repository is a separate system, often on its own servers, that both the controller and the agents can reach over the network.
Whenever you meet a new repository term, translate it into library language. Artifact is a book. Version is an edition. Repository is the shelf. Checksum is the seal on the wrapper that tells you nobody has tampered with the book.
4What Jenkins Offers on Its Own
Jenkins has some built-in ways to keep build outputs. They are useful, but they are not a replacement for a real repository.
| Feature | What it does | Best for | Limits |
|---|---|---|---|
archiveArtifacts | Saves chosen files with the build record, so people can download them from the build page | Test reports, logs, small outputs for humans to look at | Stored with the build. Deleted when old builds are discarded. No versions, no proxying |
stash and unstash | Temporarily saves files during a run so a later stage, possibly on another agent, can use them | Passing compiled output between stages of one run | Disappears when the run ends. Not meant for large files |
fingerprint | Records a checksum of a file so Jenkins can track where it was produced and used | Tracing which builds used which file | Tracking only. It does not store the file |
| Copy artifacts plugin | Lets one job fetch the archived files of another job’s build | Simple hand-offs between jobs on one Jenkins | Tied to one Jenkins server and to build retention |
| Artifact manager plugins | Store archived files in outside storage, such as a cloud bucket, instead of on the controller | Freeing controller disk space | Still not a versioned, format-aware repository |
Archiving artifacts in Jenkins is like pinning a photo to the office noticeboard. It is fine for sharing something for a few weeks. It is not a filing cabinet, and nobody expects to find last year’s photo there. A repository is the filing cabinet, with labelled folders and a retention rule.
Why the built-in tools are not enough
- They live and die with build history. When old builds are cleaned up to save space, their artifacts go too.
- They have no notion of versions or formats. A build tool cannot ask Jenkins for “library X, version 2.1”.
- They are tied to one Jenkins. Other tools and other servers cannot easily use them.
- They sit on the controller by default, which uses its disk and adds load to the most important machine in the system.
- They offer little access control per artifact, beyond who may view the build.
Archiving large files, such as many-hundred-megabyte packages, on every build fills the controller’s disk quickly. If you find yourself archiving big outputs, that is the sign it is time to publish them to a repository instead.
A good division of labour is: use archiving for small things humans look at, such as reports and logs, and use the repository for anything a machine will consume later, such as packages and images.
5Repository Types: Hosted, Proxy, and Group
Almost every repository manager offers the same three building blocks, under slightly different names. Understanding them makes the rest of the topic easy.
Hosted repository
Holds artifacts that you upload yourself. This is where your own builds are published. Some products call it a local repository.
Proxy repository
Stands in front of a public registry. The first time someone asks for a package, the proxy fetches it from the outside and keeps a copy. Some products call it a remote repository.
Group repository
Combines several repositories behind a single address. Builds point at the group and see everything in it. Some products call it a virtual repository.
flowchart TD
A["Build tool asks the group repository"] --> B{"Is it in the hosted repository"}
B -->|Yes| C["Return the internal artifact"]
B -->|No| D{"Is it already cached in the proxy repository"}
D -->|Yes| E["Return the cached copy"]
D -->|No| F["Proxy fetches it from the public registry"]
F --> G["Store a copy in the cache"]
G --> E
Think of a school library. Books the school owns are on its own shelves (hosted). For books it does not own, the librarian orders them from the city library the first time a pupil asks, and then keeps a copy for the next pupil (proxy). Pupils simply ask at one desk, and the librarian works out where the book comes from (group).
Why the group is so useful
With a group repository, your build tools need to know only one address. Behind it, you can add, remove, or reorder repositories without changing any build. The order of members matters. If two members hold an artifact with the same name, the group usually answers from the first one that has it, and that behaviour has security consequences we return to in the security chapter.
Release and snapshot spaces
Many teams also split their hosted repositories by stage of maturity. A snapshot or development repository holds work in progress and may allow overwriting. A release repository holds finished versions and refuses to overwrite them. Splitting them means a mistake in a development build can never damage a published release.
| Repository | Allows overwriting? | Who writes to it | Typical retention |
|---|---|---|---|
| Development or snapshot | Yes, newer builds replace older ones of the same version | Every successful build | Short, with automatic cleanup |
| Staging | Usually no | Pipelines that passed the first checks | Medium |
| Release | No, versions are immutable | Only the promotion step | Long or permanent |
| Proxy cache | Managed by the repository | Nobody directly | Based on cache rules |
6The Repository Manager Landscape
There are many products that can play the repository role. Here is the general landscape, without favouring any of them.
| Kind of product | Examples | Typical strengths |
|---|---|---|
| Universal repository managers | JFrog Artifactory, Sonatype Nexus Repository | Many formats in one place, proxying, promotion, fine access control, cleanup rules |
| Code-platform registries | Package registries offered by code-hosting services | Close to the source code, simple permissions that follow the repository |
| Cloud provider registries | Managed registries and package services from the large cloud providers | No server to run, integrated with cloud identity and networking |
| Container-focused registries | Registries dedicated to container images | Image scanning, signing support, replication across regions |
| Language-specific servers | Small servers for one ecosystem, such as one language’s packages | Simple to run for a single format |
You can store your belongings in a home cupboard, a rented storage unit, or a bank vault. All of them keep things safe, but they differ in cost, size, who can get in, and how much service you get. Which is right depends on what you store and how careful you need to be.
What to look for
Formats you use
Make sure it understands every package type your teams build: containers, Java, JavaScript, Python, and so on.
Proxy and caching
A good proxy speeds up builds and protects you when a public registry is slow or down.
Access control
Fine-grained permissions per repository, and support for narrow tokens, so pipelines get only the access they need.
Promotion and metadata
A way to record build information and to promote artifacts between repositories without rebuilding.
Cleanup rules
Automatic removal of old snapshots and unused images, so storage cost does not run away.
Availability
Replication, backups, and a plan for what happens when the repository is unreachable.
Products and their features change quickly. Treat any list in a guide, including this one, as a starting point, and confirm current capabilities in each vendor’s own documentation before you decide.
7Three Ways to Integrate
There is more than one way to connect Jenkins to a repository. Each has strengths, and many teams mix them.
Way one: the build tool does it
Most build tools already know how to publish and fetch. A Java build tool can deploy a package to a repository address. A JavaScript tool can publish to a registry. A Python tool can upload a wheel. A container tool can push an image. In this style, Jenkins only runs the command, and the tool does the talking. You need to give the tool the repository address and a credential. Jenkins provides the credential through its protected store and hands it to the command only for the moment it is needed.
Way two: a Jenkins plugin
Several repository vendors publish Jenkins plugins. A plugin can add pipeline steps such as “upload these files”, “download these files”, or “publish build information”, and can attach a build record to the artifact so that anyone looking at the repository can find the Jenkins build behind it. Plugins can also give you screens, links, and policy checks. The cost is one more plugin to install, secure, and keep updated.
Way three: plain web calls
Almost every repository accepts uploads and downloads over ordinary web requests. A pipeline step can call the repository’s interface directly, using a command-line web client and a credential. This works with any product and needs no plugin, but you must write and maintain the calls yourself, including error handling.
| Approach | Strengths | Weaknesses | Best when |
|---|---|---|---|
| Build tool native publishing | Simple, uses tools developers already know, works on a laptop as well as in Jenkins | Little build metadata unless the tool adds it | Standard package formats with mature tools |
| Vendor plugin or client | Rich metadata, promotion, policy checks, nice pipeline steps | Extra plugin to manage, some vendor lock-in | You use one repository product and want traceability |
| Direct web calls | Works with everything, no plugin | You maintain the scripts and their error handling | Odd file types, or small one-off needs |
To send a parcel, you can use the post office counter (the build tool), hire a courier company with tracking and insurance (the plugin), or drive to the recipient yourself (direct web calls). All three deliver, but they differ in effort, tracking, and cost.
Start with the build tool’s own publishing, since developers can test it on their own machines. Add a plugin or a client later only if you need extra traceability or promotion features that the basic path lacks.
8The Publishing Flow in a Pipeline
Let us walk through a typical pipeline, from a commit to a published artifact, and see where the repository fits.
Check out and resolve dependencies
The pipeline fetches the code. The build tool asks the repository’s group address for the libraries it needs. The proxy fetches and caches anything new.
Build and test
The pipeline compiles and runs tests. Nothing is published yet, because a failed build must never leave anything in the repository.
Decide the version
The pipeline works out a version from a rule, for example a base version plus the build number, and records the commit it came from.
Publish
Inside a narrow credential binding, the pipeline uploads the artifact to the right hosted repository. Only pipelines running on trusted branches are allowed to do this.
Record build information
The pipeline records which Jenkins build, commit, and dependencies produced the artifact, either through the plugin or through properties attached to the upload.
Hand off
Later stages, or later pipelines, fetch the artifact by name and version from the repository, not from the workspace.
A publisher does not put a book on the shelf until the proofreading is done. It also stamps the edition number and the print date inside the cover. Only then does the book go to the warehouse, and the shops order it from the warehouse, never from the print room.
Only publish what passed
A key rule is to publish only after the build and its tests have succeeded. Otherwise, the repository fills with broken artifacts that people might use by mistake. A second rule is to publish only from trusted branches. A build from an experimental branch or an outside contribution should not be able to write into your main development or release repository.
Uploads should be a single, well-defined step. If a pipeline uploads some files, fails, and leaves the rest missing, the repository holds a half-published release. Publish all files of one version together, and make the step safe to rerun.
9Resolving Dependencies Through the Repository
The repository is not only where builds end. It is also where they begin, by supplying the libraries a build needs.
Modern software depends on many outside libraries. A single project may pull in hundreds of packages, directly and indirectly. Without a repository, every build on every agent would download all of them from the public internet, again and again. With a proxy repository in between, each package is downloaded from outside once, cached, and then served locally to everyone.
Benefits of resolving through your own repository
Local downloads
Packages come from a nearby server instead of across the internet, which saves minutes per build.
Independence from outages
If a public registry is slow or down, cached packages are still available, and builds keep running.
One gate for everything
You can block bad packages, require scans, or restrict which outside sources are allowed, in one place.
Stable versions
A cached package stays available even if the original is later removed from the public registry.
How the build tool is pointed at it
Each build tool has a setting for where to fetch packages. You point it at the group repository’s address, and give it a credential if the repository needs one. Teams often keep this setting in a shared configuration file, provided to the agents through Jenkins, so that nobody has to edit each project. Jenkins can supply such a file through a config file feature, and can fill in the credential from its protected store.
A building site does not send a worker to the shop for every nail. The site keeps a stock cupboard, refilled from the shop when it runs low. Workers take nails from the cupboard in seconds, and the site keeps working even if the shop is closed for a day.
Read access should be cheap and wide, write access narrow
Pull requests and feature branches need to read dependencies but must never publish. Give read-only access to the whole build fleet, and give write access only to the pipelines that publish. Repository products let you create separate tokens for these two purposes.
Measure the effect. Time a build with a cold cache, and again with a warm one. The difference is the time your repository saves on every build, and is a helpful number to share when asking for budget for it.
10Versioning and Naming
A repository is only as useful as the labels on its contents. Good versions and names make everything else easier.
Snapshots and releases
Many ecosystems distinguish two kinds of versions. A snapshot or development version is a moving target, meaning “the latest work towards version 2.4”. It may be overwritten by each new build. A release version is a fixed point, such as 2.4.0, and must never change. If a release version could be replaced with different contents, nobody could trust it, so good repositories refuse to overwrite it.
| Kind | Example label | May change? | Use for |
|---|---|---|---|
| Snapshot or development | 2.4.0-SNAPSHOT, or a version with a build number | Yes, often | Day-to-day builds and sharing work in progress |
| Release candidate | 2.4.0-rc.1 | No | Final testing before a release |
| Release | 2.4.0 | Never | Production deployments |
| Patch release | 2.4.1 | Never | Fixes to an existing release |
Semantic versioning in one paragraph
A popular convention, known as semantic versioning, uses three numbers: major, minor, and patch. A change to the major number signals changes that may break users. A change to the minor number adds features in a compatible way. A change to the patch number fixes bugs. Following such a rule lets consumers guess how risky an upgrade is, just by reading the number.
Tying versions to builds
Many pipelines build a version from the base version plus the Jenkins build number, for example 2.4.17, where 17 is the seventeenth build of that line. Others append the short commit id. Either way, the aim is that the version alone lets you find the exact build and the exact commit. Some teams also store the commit id, the build URL, and the branch name as properties on the artifact in the repository.
A printed book has an edition number, and the publisher never changes the contents of “second edition” once it is on the shelves. Any change makes a “third edition”. Notes in the margin of a draft manuscript, on the other hand, change daily. Snapshots are the draft. Releases are the printed edition.
Naming conventions that pay off
- Use a company namespace in every package name, so your names cannot clash with public ones.
- Use lowercase and dashes consistently, so names are easy to type and search.
- Separate repositories by format and by maturity, such as one for release packages and one for snapshots.
- Avoid moving labels in production. A tag such as “latest” points at different contents on different days, which makes rollbacks and audits confusing.
Rebuilding “the same version” after a fix, and trying to overwrite the release, is one of the most common repository mistakes. Either the repository refuses, and the pipeline fails, or it accepts, and consumers who cached the old file now hold something different under the same name. Always move to a new version number.
11Promotion: Build Once, Deploy Many
Promotion is the idea that makes the whole integration worth having. An artifact earns its way to production by passing checks, without ever being rebuilt.
A promotion moves or copies an artifact from one repository to another, for example from staging to release, after it has passed a set of checks. The file itself is not rebuilt. Its contents do not change by a single byte. Only its location, and often a status label such as “tested” or “approved”, changes. The promotion is recorded in the repository’s history, so you can see who promoted what, and when.
sequenceDiagram
participant J as Jenkins Pipeline
participant S as Staging Repository
participant Q as Quality Checks
participant R as Release Repository
participant D as Deployment Stage
J->>S: Upload the build output with build information
J->>Q: Run tests and security scans on the staged artifact
Q-->>J: Results of the checks
J->>R: Promote the same artifact if all checks passed
D->>R: Download the promoted artifact
D->>D: Deploy the exact same bytes
A new medicine is made in one batch. That batch passes laboratory tests, safety checks, and a final approval. It is then moved from the quarantine shelf to the approved shelf. Nobody re-manufactures the medicine to give it a new label. The tested batch is the shipped batch.
What promotion gives you
What you tested is what you ship
The same bytes reach production that passed the tests, with no rebuild risk in between.
Clear stages
Repositories or status labels show at a glance which artifacts are in testing and which are approved.
Easy rollback
The previous release is still there. Rolling back means deploying an older version, not rebuilding from an old commit.
Audit trail
Who promoted which version, when, and on the basis of which checks, is recorded.
Who is allowed to promote
Promotion is a powerful action, since it decides what may reach production. Give the right to write into the release repository only to the promotion step, and let that step run only in a controlled pipeline, often behind a human approval. Ordinary build pipelines should not be able to write to the release repository at all.
Have the deployment stage fetch its artifact by exact version from the release repository, and record that version in the deployment log. Then the answer to “what is running in production?” is a lookup, not a guess.
12Container Images and Registries
Container images are the most common artifact today. They follow the same ideas, with a few special features of their own.
A container image is a packaged file system plus instructions for running an application. A registry is the repository that stores images. Many general-purpose repository managers also work as image registries, and there are registries designed only for images.
How a pipeline works with images
Build the image on an agent
The pipeline runs the image build using the application’s build output, and gives the image a name that includes the registry address.
Tag it meaningfully
The tag includes the version and the commit, so the image can be traced. A moving tag such as “latest” is added at most as a convenience, never used for deployment.
Log in narrowly and push
Inside a narrow credential binding, the pipeline logs in to the registry and pushes the image. The login lasts only as long as the block.
Scan and sign
The image is scanned for known vulnerabilities, and where the organisation requires it, it is signed so that clusters can check its origin.
Deploy by digest or exact tag
The deployment refers to the image by its exact version, or by its digest, which is a checksum of its contents that can never point at anything else.
A shipping container has a name painted on the side, but also a unique serial number. The painted name might be repainted, but the serial number always identifies exactly that box. A tag is the painted name and a digest is the serial number. For safety, order by the serial number.
Points that are special to images
- Images are made of layers, so repeated pushes are fast when most layers are unchanged, and storage grows more slowly than file sizes suggest.
- Old layers pile up, and cleanup needs a garbage collection step in the registry.
- Base images matter. Pull them through a proxy, choose trusted ones, and rebuild regularly to pick up fixes.
- Agents need the container tooling, and Docker-in-Docker or similar setups deserve careful security review.
- Rate limits on public registries can break builds that pull base images directly. A proxy avoids this.
13How It Works Internally
This chapter lifts the lid. Knowing what happens during an upload and a download makes many puzzling errors easy to explain.
What happens on an upload
When an agent uploads an artifact, it opens a network connection to the repository, proves who it is with a credential, and sends the file together with its address. The repository checks that the credential has the right to write to that repository. It then checks the rules for that repository, for example whether overwriting is allowed. It computes checksums as the file arrives and compares them to any checksums the client sent. If everything matches, it stores the file, records its details in an index, and updates any metadata files that describe the available versions. The pipeline receives a success answer only after all of this is done.
A warehouse receiving desk checks your delivery slip, checks that you are allowed to deliver, counts and weighs the boxes against the list, writes them into the stock book, and only then signs your receipt. Each of those checks is a point where a delivery can be refused.
What happens on a download
A build tool asks for an artifact by its address. The repository looks it up. If the address points at a group, the repository checks each member in order. If a proxy member holds a cached copy, that copy is returned. Otherwise the proxy fetches the file from the outside registry, checks it, caches it, and returns it. The client normally verifies the checksum after download.
The role of checksums
A checksum is a short value calculated from the exact contents of a file. Change one byte, and the checksum changes. The repository stores checksums beside each artifact, and clients check them after download. This catches corrupted transfers and helps show that a file has not been tampered with in storage or in transit. Stronger protection uses digital signatures, where a trusted key vouches for the file.
Where the credential comes from
- Jenkins stores the repository token in its protected credentials store, with a scope that limits which jobs can reach it.
- When the pipeline reaches the publishing step, Jenkins decrypts the token on the controller and sends it to the agent only for that block.
- The agent gives it to the build tool, usually through an environment variable or a temporary configuration file.
- When the block ends, the temporary file is removed, and the token leaves the agent’s environment.
Build information and fingerprints
To connect an artifact to its build, a pipeline can attach properties to the upload, or use a vendor plugin to publish a record of the build. In addition, Jenkins can compute a fingerprint for the file, so that its own pages can show which other jobs used it. Together these give traceability in both directions: from the build to the artifact, and from the artifact back to the build.
The details differ from product to product. The general sequence of authenticate, authorise, validate, store, and index is common to them all, and a clear mental picture of it helps you read error messages and logs.
14Performance, Scalability, and Cost
A repository can make builds much faster, or much slower, depending on how it is set up. This chapter shows where the time and money go.
Where the time goes
In a pipeline that uses a repository, time is spent in three places: downloading dependencies at the start, uploading artifacts at the end, and downloading artifacts again when deploying. Each of these depends on the size of the files, the speed of the network path between the agent and the repository, and how busy the repository is.
The numbers above are only an illustration. Without a proxy, sixty builds times three hundred megabytes is eighteen gigabytes fetched from the public internet each day. With a warm proxy cache, the outside download happens roughly once, about three hundred megabytes, and the remaining traffic stays inside your own network.
A family that buys milk every day from a shop across town spends an hour a day in the car. A family that buys a week of milk on Saturday and keeps it in the fridge spends the same hour once a week. The proxy is the fridge.
Ways to keep it fast
Place the repository near the agents
Short network paths and fast links matter more than any setting. Put the repository in the same region or data centre as most of your agents.
Use proxies and caches
Resolve all dependencies and base images through proxy repositories, and warm them ahead of busy periods.
Publish once, not many times
Upload the artifact a single time, and let every later stage download it from the repository.
Keep artifacts lean
Exclude test data and build leftovers from packages, and use small base images for containers.
Use layers and incremental uploads
For images, order the build so that rarely changing layers come first and are reused between builds.
Replicate for distant sites
Teams in different regions can use nearby copies, kept in step by replication.
Storage cost and retention
Storage grows quietly. Suppose each build produces an eighty-megabyte package and the team does sixty builds a day. That is 4.8 gigabytes a day, or about 144 gigabytes over a thirty-day retention window for snapshots. Release versions are usually kept far longer, and container images add layers of their own. Without cleanup rules, storage cost only ever rises.
| Kind of content | Suggested retention approach | Reason |
|---|---|---|
| Development snapshots | Keep the newest few per version, and delete anything older than a few weeks | Rarely needed after newer builds exist |
| Staging artifacts | Keep for a medium period, tied to release cycles | Needed for investigating recent problems |
| Released versions | Keep long term, sometimes permanently | Rollbacks, audits, and legal or contractual needs |
| Proxy caches | Expire unused items after a set time | Can always be fetched again from the source |
| Container images | Delete untagged and old snapshot images, then run garbage collection | Layers accumulate fast |
Set cleanup rules on day one. Adding them after a year of growth is stressful, because nobody remembers which old artifacts are still in use.
15Reliability and Availability
Once every build depends on the repository, the repository becomes part of your delivery infrastructure. It must be dependable.
A new single point of failure
Before the integration, a build needed only Jenkins and the internet. Now it needs Jenkins, the repository, and the network between them. If the repository is down, builds cannot fetch dependencies, and deployments cannot fetch artifacts. A repository that is slow or unreachable can stop the whole company from shipping.
| Failure | Effect | Protection |
|---|---|---|
| Repository unreachable | Builds fail at dependency resolution, and deployments cannot fetch artifacts | High-availability setup, or a standby, plus alerts |
| Public registry down | New packages cannot be fetched | Proxy cache holds previously used packages |
| Network hiccup during upload | A partial or failed upload | Retry with a limit, and make uploads safe to repeat |
| Disk full on the repository | Uploads are refused | Storage alerts and retention rules |
| Expired or rotated credential | Authentication failures across many pipelines at once | Rotation plan with overlap, and expiry warnings |
| Corrupted or lost artifact | A release cannot be redeployed | Backups, checksums, and replication of releases |
A supermarket that depends on a single warehouse must plan for the warehouse being closed by snow. It keeps a few days of stock in its own back room and has a phone number for a second warehouse. A proxy cache is the back room, and replication is the second warehouse.
Pipeline habits that help
- Retry with limits. A short retry, with a few attempts, smooths over brief network problems. Endless retries hide real outages.
- Timeouts. Give every upload and download a maximum time, so a stuck transfer cannot hold an executor for hours.
- Safe reruns. Uploading the same version twice should either succeed harmlessly or fail clearly, never leave a half-state.
- Fail early. Check the repository is reachable at the start of a pipeline, so developers learn about a problem in seconds, not after twenty minutes of building.
- Verify after publishing. Confirm the file is present and its checksum matches, before telling later stages to fetch it.
Protecting the repository itself
Treat the repository like a production system. Back up its data and configuration, test the restore, monitor its disk and response time, and keep it patched. Because it holds the only copy of past releases, losing it can be more painful than losing a source code server, since source can be rebuilt, but builds rebuilt long afterwards may differ.
Rotating a repository token that many pipelines share can break every one of them at once. Use narrow tokens per team or per purpose, and rotate them with an overlap period in which the old and new values both work.
16Security Considerations
A repository sits right in the middle of your software supply chain. Whatever it serves ends up inside your products, so its security matters a great deal.
Over-powerful tokens
A token that can write to every repository turns any leak into a disaster. Give pipelines tokens limited to the repository and the action they need.
Dependency confusion
An attacker publishes a package on a public registry with the same name as one of your internal packages, and a high version number. A badly ordered group repository may fetch the attacker’s copy.
Tampered or malicious packages
A public package may contain harmful code. Scanning and policy checks at the proxy can block known-bad content.
Untrusted builds publishing
A pull request from a stranger that can upload to your repository could plant harmful artifacts. Only trusted branches should publish.
Mutable releases
If a release can be overwritten, an attacker, or a mistake, can swap its contents while the version number stays the same.
No record of origin
Without build information and signatures, nobody can prove where an artifact came from.
Habits that protect you
- Least privilege. Read-only tokens for building and testing. Write tokens only for the publishing step. Promotion rights only for the promotion step.
- Use Jenkins credential scopes. Store repository tokens in the team’s folder, so other teams’ pipelines cannot use them.
- Defend against dependency confusion. Use company namespaces for internal packages, and configure the group so that internal names are resolved only from your hosted repositories, never from a public proxy.
- Make releases immutable. Turn off overwriting in release repositories.
- Scan on the way in and on the way out. Check downloaded dependencies and your own artifacts for known vulnerabilities and licence problems.
- Record and sign. Attach build information to each artifact, keep a list of what is inside it, often called a software bill of materials, and sign artifacts where your process demands it.
- Deploy by checksum or digest. Make the deployment stage verify what it downloaded.
- Protect the repository server. Patch it, restrict its network exposure, and log all administrative actions.
A restaurant checks every delivery against the order, refuses anything with a broken seal, and keeps a record of which supplier brought which batch. If a customer falls ill, the restaurant can trace the batch and remove it. Dependency scanning, checksums, and build records do the same for software.
17Monitoring, Logging, and Troubleshooting
When an upload fails or a download is slow, here is how to find the cause calmly.
What to watch
- Jenkins build logs. Show the exact command, the error message, and the exit status, with secrets masked.
- Repository logs and audit records. Show who tried what, and why it was refused.
- Repository health. Disk space, response time, error rate, and queue of requests.
- Transfer sizes and durations. A sudden jump often means a package changed shape, or a cache went cold.
- Build information links. From an artifact in the repository, jump back to the Jenkins build that made it.
flowchart TD
A["Upload or download fails"] --> B{"Is it an authentication or permission error"}
B -->|Yes| C["Check the Jenkins credential and its scope, and the token permissions"]
B -->|No| D{"Is it a not found error"}
D -->|Yes| E["Check the repository name, the coordinates, and the group members"]
D -->|No| F{"Is the overwrite refused"}
F -->|Yes| G["A release version already exists so use a new version"]
F -->|No| H{"Is it a timeout or a slow transfer"}
H -->|Yes| I["Check the network path, the proxy, the file size, and repository load"]
H -->|No| J["Read the repository log and the full response message"]
Common symptoms and causes
| Symptom | Likely cause | What to do |
|---|---|---|
| Unauthorized or forbidden on upload | Wrong or expired token, or no write permission on that repository | Check the Jenkins credential scope and the token’s rights |
| Not found on download | Wrong coordinates, or the artifact is in a repository that the group does not include | Check spelling, version, and group membership |
| Upload refused as duplicate | A release version already exists and overwriting is off | Increase the version |
| Build suddenly slow | Cold cache, changed dependencies, or an overloaded repository | Check cache hits and repository load |
| Wrong version deployed | A moving tag was used, such as latest | Deploy by exact version or digest |
| Checksum mismatch | Corrupted transfer, or a changed file under the same name | Retry once, then investigate how the file changed |
| Storage full | Retention rules missing or too generous | Add cleanup rules and free space |
| Rate limit errors from a public registry | Builds pull directly instead of through a proxy | Route pulls through the proxy repository |
Numbers worth tracking over time
Track the time of dependency resolution and of publishing in each pipeline. Track the cache hit rate of proxy repositories. Track storage growth per repository, and the number of failed uploads and downloads per week. A weekly look at these charts turns surprises into planned changes.
18Design Patterns and Anti-patterns
Patterns are habits that keep delivery calm. Anti-patterns are habits that keep causing incidents.
Patterns that help
Build once, promote
One artifact per commit, moved through repositories as it passes checks.
Everything through the group
All builds resolve packages from one group address, so policy and caching happen in one place.
Immutable releases
Release repositories refuse overwrites. A fix is always a new version.
Separate tokens by purpose
Read, write, and promote rights use different credentials in different scopes.
Traceable versions
Every artifact carries the build number, commit, and branch, so it maps back to Jenkins in one click.
Deploy from the repository
Deployment stages download the artifact by exact version and never use workspace files.
Anti-patterns to avoid
Context
A team rebuilds the software separately for testing, staging, and production, each time from the same branch.
What goes wrong
A dependency updates between the staging and production builds. Production runs code that was never tested, and a bug appears that no earlier stage could have caught.
Better decision
Build once, publish to the repository, and promote the same artifact through each stage.
Context
Deployments use an image tag called “latest”, which every build overwrites.
What goes wrong
Nobody can say which build is running. A rollback means guessing which older image to restore, and two servers pulling at different moments may run different code under the same name.
Better decision
Tag every image with a version and commit, and deploy by exact version or digest.
Context
One shared administrator token is used by every pipeline to read, write, and promote.
What goes wrong
A leak in any pipeline exposes the whole repository, including releases. Rotating the token breaks every pipeline at once, so it is never rotated.
Better decision
Create narrow tokens per team and per purpose, store them in the team’s Jenkins folder, and rotate them on a schedule with overlap.
Context
Build outputs are archived in Jenkins for months, and downstream jobs fetch them from old builds.
What goes wrong
The controller’s disk fills. When old builds are discarded, downstream jobs suddenly cannot find their inputs, and nobody can restore them.
Better decision
Publish to a repository with its own retention rules, and let downstream jobs fetch by version.
19Advantages, Trade-offs, Best Practices, and Common Mistakes
A balanced view of repository integration, and the habits that keep it working for you.
Advantages
- Every build output has a durable, versioned home.
- Build once, deploy many: what you tested is what you ship.
- Faster builds through proxy caches.
- Independence from public registry outages.
- Easy rollbacks by redeploying an older version.
- Traceability from artifact to build to commit.
- One place to enforce security and licence policy.
Disadvantages and trade-offs
- Another system to run, secure, back up, and pay for.
- A new single point of failure for builds and deployments.
- Storage grows without cleanup rules.
- More credentials to manage and rotate.
- Vendor plugins add lock-in and upgrade work.
- Teams must learn versioning and promotion discipline.
Best practices in one place
- Build once and promote. Never rebuild between test and production.
- Publish only after success, and only from trusted branches.
- Deploy from the repository, by exact version or digest, never from a workspace.
- Make release versions immutable. A fix is always a new version.
- Resolve everything through a group repository with proxies, so builds are fast and policy is central.
- Defend against dependency confusion with namespaces and repository routing rules.
- Use narrow tokens, one per purpose, stored in the right Jenkins credential scope and bound only where needed.
- Attach build information and checksums to every artifact, and sign where required.
- Set retention and cleanup rules from the start, and watch storage growth.
- Add timeouts and limited retries to every upload and download.
- Back up the repository and test restoring it, since it holds your release history.
The mistakes seen most often
Mistake 1: publishing from every branch
Every feature branch uploads into the main development repository. It fills with half-finished artifacts, and someone eventually deploys one by mistake. The fix is to publish only from trusted branches, or to a separate space for branch builds with fast cleanup.
Mistake 2: overwriting a release
A bug is found in version 2.4.0, and the team republishes 2.4.0 with the fix. Machines that cached the old file keep it, and now two different files carry one name. The fix is to publish 2.4.1 and make release repositories refuse overwrites.
Mistake 3: pulling directly from public registries
Builds fetch dependencies straight from the internet. A rate limit or an outage stops every pipeline at once. The fix is to route all pulls through a proxy repository.
Mistake 4: no cleanup
A year of snapshots and untagged images fills the disk, and uploads start failing on a Friday afternoon. The fix is retention rules and storage alerts from the beginning.
Mistake 5: one token to rule them all
All pipelines share a token with full rights. One leaked log line exposes everything. The fix is narrow tokens per team and purpose.
20Worked Scenario: From Copied Files to a Proper Repository
Let us follow one imaginary team as it replaces file copying with a repository, one step at a time.
The starting point
A team of twelve builds a web service. Their Jenkins pipeline compiles the code, runs tests, and then copies the packaged file from the workspace to the test server, and later to the production server, using a secure copy command. The team does about sixty builds a day, and each build downloads roughly three hundred megabytes of dependencies from public registries. When a bad release reaches production, the team rebuilds the previous commit, which takes about twenty-five minutes and does not always produce the same result. Nobody can say for sure which commit is running on the test server.
Set up the repository with three kinds of repositories
They create a hosted development repository, a hosted release repository that refuses overwrites, a proxy for the public registry, and a group that combines the hosted and proxy repositories.
Point builds at the group
A shared configuration file, delivered to agents by Jenkins, tells the build tool to fetch everything through the group. The first build warms the cache, and later builds use it. Daily downloads from the internet drop from about eighteen gigabytes to a few hundred megabytes.
Publish with a clear version
After tests pass on the main branch, the pipeline builds a version from the base version and the build number, and publishes the package to the development repository with the commit and build link attached. It uses a narrow write token stored in the team’s Jenkins folder and bound only around the publishing step.
Deploy from the repository
The test deployment stage downloads the exact version from the development repository. It no longer copies anything from the workspace, and it records the version deployed.
Promote after approval
After the checks pass and a person approves, a separate promotion pipeline moves the same artifact into the release repository. The production deployment downloads it from there.
Add retention and protection
Development snapshots are cleaned up after thirty days, releases are kept, and the team sets alerts on storage and on failed uploads.
| Measure | Before | After |
|---|---|---|
| Daily internet download for dependencies | About 18 GB | About 0.3 GB, with the rest served from cache |
| Time to roll back a bad release | About 25 minutes, by rebuilding | About 3 minutes, by redeploying the previous version |
| Knowing which commit runs on each server | Guesswork | A lookup from the version |
| Risk that production differs from what was tested | Real, since builds were repeated | None from rebuilds, since the same file is promoted |
| Who can write to production releases | Anyone with server access | Only the promotion pipeline |
Moving from copying files to using a repository is like a shop that stops handing customers whatever is on the packing bench, and starts using a stockroom with labelled shelves and a stock book. The first Monday is more work. Every Monday after that is calmer.
The numbers here are made up to show the pattern. Migrate one service at a time, and keep the old copy-based path working until the new one has proven itself for a few releases.
21Real-World Usage Patterns
Here is how repositories tend to be arranged in real delivery pipelines. These are illustrative patterns in general terms, not claims about the private setups of any particular company.
Jenkins is one of the most widely used automation servers, and repository managers are a common companion to it in organisations of every size. What tends to be common is a habit of building once, routing all dependencies through one gate, and keeping release history safe. The patterns below show that habit in practice.
Pattern: a small team with one universal repository
A team of ten runs a single repository manager for Java packages and container images. It has a development space with automatic cleanup and a release space that never overwrites, and one proxy for each public registry it uses.
Pattern: a regulated company with strict promotion
A financial company promotes artifacts through testing, security review, and approval repositories. Each promotion is recorded with who approved it, so an auditor can trace any production version back to its build and its sign-off.
Pattern: a global company with regional replicas
An organisation with teams on several continents keeps a main repository and replicas in each region. Builds fetch from the nearest replica, and releases are copied to every region automatically.
Pattern: an open source project with a public registry
A project builds on a Jenkins server, publishes snapshots to a development space for contributors, and publishes signed releases to a public registry only from a protected release pipeline.
Pattern: cloud-native teams using a managed registry
A team that runs on a large cloud provider uses that provider’s managed registry for images and packages. Access follows the cloud’s identity system, and Jenkins agents in the same cloud pull and push without leaving the provider’s network.
Jenkins is often used together with Docker, Kubernetes, and cloud platforms. In these settings, the repository is the hand-over point between the build system and the runtime system, which is why its reliability and security deserve as much care as either of them.
22Frequently Asked Questions
23Summary and Key Takeaways
Key Takeaways
- An artifact repository is the durable home of build outputs. It stores versioned artifacts, serves dependencies, and replaces fragile workspace copies and short-lived Jenkins archives.
- Build once, promote, deploy the same bytes. Promotion moves a tested artifact between repositories without rebuilding, so what was tested is what ships.
- Use hosted, proxy, and group repositories together. Hosted holds your own builds, proxies cache public packages, and a group gives builds a single address and a single policy gate.
- Version carefully. Snapshots may change, releases never do, and every version should map back to a Jenkins build and a commit.
- Protect the supply chain. Use narrow tokens in the right Jenkins credential scope, defend against dependency confusion, scan and sign artifacts, and publish only from trusted branches.
- Plan for failure and growth. Add timeouts, limited retries, backups, replication, and retention rules, because the repository becomes a critical dependency for every build.
- Deploy from the repository by exact version or digest. Avoid moving tags such as latest, and record what was deployed so rollbacks are a lookup and not a rebuild.