What Is Archiving Artifacts in Jenkins?

What Is Archiving Artifacts in Jenkins?

A plain-English guide to saving the files a build produces: what an artifact is, how archiving works, where the files live, how to find them later, and how to keep storage tidy, safe and useful.

Imagine a bakery where every loaf is baked in a kitchen that is scrubbed clean the moment the baking is done. The bread is perfect, but if nobody carries it out of the kitchen before the cleaning crew arrives, it goes straight into the bin. Jenkins builds work in a very similar way. A build makes something useful, such as an installable package, a test report or a screenshot, and then the temporary workspace where it was made is often wiped or thrown away. If you want to keep what was made, you must carry it out of the kitchen on purpose. In Jenkins, that act of carrying is called archiving artifacts.

Many beginners run builds for months without ever archiving anything, and then one day someone asks, “Can I download the version from last Tuesday?” and the answer is “It is gone.” In this guide you will learn what an artifact is, how archiving works, where the saved files live, how to fetch them again, and how to keep storage healthy as builds pile up. Every new word is explained when it first appears, so you can read from top to bottom without stopping.

WWhat Is Archiving Artifacts?

Archiving means telling Jenkins, “Please keep these files, and attach them to this build forever, or until I say otherwise.”

Start with the basics. Jenkins is an automation server, a program that stays switched on and does tasks for you. A job is the saved description of a task, and a build is one single run of that job. While a build runs, it works inside a folder on a machine called an agent. That folder is the workspace, and it is like a temporary desk. Files appear on the desk while the build works, and the desk is often cleaned afterward, or reused by the next build, or lost entirely if the agent is a short-lived container.

An artifact is any file that a build produces and that you want to keep. Common examples are an installable program, a compressed bundle of a website, a container package, a test report, a screenshot from a failed test, a log file, or a file of measurements. Archiving is the step where Jenkins copies chosen files from the workspace to a safe place and attaches them to that build’s record. After that, anyone with the right permission can open the build page and download those files, even years later, no matter what happened to the workspace.

Everyday Analogy

Think of an exam hall. Students write on scratch paper while they work, and the scratch paper is thrown away at the end. But the final answer sheet is collected, stamped with the student’s name and date, and filed in a cabinet. Archiving is the collecting, stamping and filing. The workspace is the scratch paper. The artifact is the answer sheet.

The most important idea is that an archived artifact belongs to a specific build. If build 57 archived a file called shop.zip and build 58 archived a different shop.zip, both files are kept, each attached to its own build. You can always say, “Give me the package that build 57 made.” That is very different from a shared folder, where the newest file overwrites the older one.

i
Tip

Ask yourself, “If this build disappeared tomorrow, which files would I still need?” Those are your artifacts. Everything else, such as temporary files and downloaded tools, can safely be thrown away with the workspace.

1 build
owns each set of archived files
Workspace
is temporary, artifacts are not
Download
from the build page, any time

What teams commonly archive

Deliverable

Installable packages

The program, library or app file that the build exists to create.

Evidence

Test reports

Files that list which tests passed and failed, so people can inspect them later.

Debugging

Screenshots and recordings

Pictures or videos captured when a user-interface test fails.

Debugging

Log files

Detailed logs from tools and servers used during the build.

Quality

Coverage and scan results

Reports on how much code was tested or which weaknesses a scan found.

Audit

Release notes and checksums

Small files that describe what a release contains and prove that it was not altered.

HA Short History: Why Build Outputs Needed a Home

The idea of keeping build results is as old as build servers themselves, and it grew from a very practical frustration.

In the early days of automated builds, a build server compiled the code, reported “success,” and that was the end. If a tester wanted to try the result, someone had to log into the build machine and copy files by hand from a folder. Which folder? Which version? Was it overwritten by the next run? Nobody knew for sure. Teams often ended up with folders named final, final2 and really-final, and nobody trusted any of them.

Early Hudson, which later became Jenkins, solved this by adding a simple feature: after a build, choose some files, and the server would store them next to the build’s record. Each build carried its own files, and the web page showed a download link. This tiny idea, “attach the output to the build that made it,” turned the build server from a passing judge into a reliable library of every version ever produced.

Everyday Analogy

Picture a photocopy shop that once handed out copies from a shared tray. Copies mixed, got lost and were overwritten. Then the shop began putting each customer’s copies in a labeled envelope with the order number. Suddenly everybody could find exactly what they had asked for. Archiving artifacts gave Jenkins the labeled envelope.

1

Early build servers

Results were left in a folder on the build machine, easily overwritten and hard to trace.

2

Hudson adds archiving

Chosen files are copied and attached to the build that produced them, with download links on the build page.

3

Fingerprints arrive

Jenkins can record a short unique code for each file, so it can tell which build produced a file found elsewhere.

4

Pipelines make it a step

Archiving becomes one line in a pipeline recipe, alongside stashing files between stages.

5

External artifact storage grows

Dedicated repositories and cloud storage plugins take over the heavy, long-term storage, while Jenkins keeps links.

!
Do not confuse the words

In everyday language, “archive” can mean an old, rarely used store. In Jenkins, archiving simply means “save these files with this build.” It says nothing about being old or rarely used. A file archived a minute ago is just as archived as one archived a year ago.

CCore Concepts You Need to Know

A handful of small ideas explain almost everything about artifacts. Learn them once and the rest of the guide is easy.

File

Artifact

Any file produced by a build that you choose to keep, such as a package or a report.

Action

Archive

Copy chosen files from the workspace to storage and attach them to the build.

Folder

Workspace

The temporary folder on the agent where a build works and where artifacts are first created.

Pattern

File pattern

A short text with wildcards that tells Jenkins which files to pick, such as “all zip files in the output folder.”

Code

Fingerprint

A unique code calculated from a file’s contents, used to recognize the same file in different places.

Move

Stash

A short-term way to pass files between stages of one build. It is not permanent storage.

Store

Artifact repository

A dedicated warehouse system for packages, designed for long-term, shared, versioned storage.

Rule

Retention

The rule that decides how many builds and artifacts to keep, and for how long.

Job, build, workspace and artifact together

A job is the recipe, and each run of it is a build. During a build, the agent works in a workspace. The controller, the main Jenkins server, keeps the build record. When the build archives artifacts, the files travel from the agent’s workspace to storage managed by the controller, and the build record then lists them.

Everyday Analogy

A restaurant again. The cook (agent) prepares a dish on a private counter (workspace). The head waiter (controller) writes the order into a book (build record). If the customer wants a takeaway box, the cook puts the dish in a box, and the head waiter writes “one box, made for order 57” in the book. The box is the artifact, and the note in the book is what lets you find it later.

i
Tip

Only files can be archived, and only files that are inside the build’s own workspace. If a tool writes its output somewhere else on the machine, copy it into the workspace first, then archive it.

AArchitecture: Where Artifacts Travel and Live

An artifact starts life on an agent and ends up in storage. Seeing the trip explains how downloads, disk space and speed are connected.

flowchart LR
    Dev["Developer"] -->|"push code"| SCM["Git Repository"]
    SCM -->|"webhook"| Ctrl["Jenkins Controller"]
    Ctrl --> Queue["Build Queue"]
    Queue --> Agent["Agent"]
    Agent --> WS["Workspace with output files"]
    WS -->|"archive step"| Store["Artifact Storage"]
    Store --> Rec["Build Record"]
    Rec --> UI["Build Page with Download Links"]
    Agent -->|"large or long-lived files"| Repo["External Artifact Repository"]
    Users["Testers and Teammates"] --> UI
    Users --> Repo
Figure 1: How an artifact travels from a workspace to storage and to the people who need it.

Reading the diagram

Follow the arrows from the left. A developer pushes code to a Git repository, the shared place where the team keeps its source code. The repository sends a webhook to the Jenkins controller, which puts a build request into the build queue. When an agent has a free executor, the build runs there and creates files in its workspace. At the archive step, chosen files travel to artifact storage and are listed in the build record. The build page then shows download links. For very large or long-lived files, teams often send them instead to an external artifact repository, a warehouse built for packages. Testers and teammates then fetch what they need from either place.

Where the files live by default

By default, Jenkins stores archived artifacts on the disk of the controller, inside the Jenkins home folder, in a directory that belongs to that specific build. This has advantages and one big drawback. The advantage is simplicity: nothing extra to install, and backups of the home folder include artifacts. The drawback is that the controller’s disk is precious. It also holds job settings, credentials and build history. If artifacts fill that disk, the whole Jenkins can stop working.

!
The controller disk is not a warehouse

Never treat the controller’s disk as unlimited storage. A single build that archives a two-gigabyte package, run fifty times a day, needs a hundred gigabytes a day. Plan for this before it happens, by trimming what you archive, by discarding old builds, or by sending large files to a proper repository.

Storage options at a glance

OptionWhere files liveGood forWatch out for
Default archivingController disk, next to the build recordSmall files, reports, logs, quick startsDisk fills fast when files are large
Cloud storage pluginObject storage in the cloud, with Jenkins keeping the linksLarger files and many buildsNeeds setup, credentials and cost tracking
Artifact repositoryA dedicated system for packages, outside JenkinsReleases, shared packages, long-term versioningAnother system to run and secure
Container registryA store for container imagesContainer-based deliveryImages are not ordinary files on the build page

HHow Archiving Works Internally

Under the friendly download links, Jenkins performs a small, careful copy operation. Knowing its steps explains many surprises.

Step by step

1

The build creates files

Tools such as compilers, test runners and packagers write their output into the workspace on the agent.

2

The archive step starts

The build reaches the archive step, either as a post-build action in a classic job or as a step in a pipeline.

3

The pattern is matched

Jenkins looks in the workspace for files that fit your file pattern. Only matching files are chosen.

4

Files are transferred

The chosen files are sent from the agent to the controller, or to the configured storage, over the connection that already links them.

5

The build record is updated

The files are stored under the build’s own directory and listed on its page, keeping their folder layout.

6

Optional fingerprints are recorded

If requested, Jenkins calculates a unique code for each file and stores it, so the file can be traced later.

7

The workspace is free to be cleaned

Now that the files are safe, the workspace can be wiped without losing anything important.

Everyday Analogy

Think of packing for a move. You walk through the house with a list, “all the boxes labeled kitchen,” and pick only those. Boxes go onto the truck, the truck delivers them to a storage unit, and a receipt records what went in. Only then do you feel safe to empty the old house. The file pattern is your list, the transfer is the truck, and the build record is the receipt.

File patterns in plain words

You tell Jenkins which files to keep with a file pattern. A pattern is a short line of text where a star stands for “anything here.” A single star matches any name inside one folder. A double star matches through any number of folders. You can list several patterns separated by commas, and you can also list patterns to exclude. The habit to build is being specific. A pattern that says “everything” will also grab temporary files, downloaded tools and folders full of junk, and your storage will fill with things nobody needs.

What you wantHow to describe it in words
Only the final packageThe zip files in the output folder
All reports in any subfolderEvery xml file anywhere under the reports folder
Everything except large logsAll files in the results folder, excluding files ending in log
Screenshots from failed testsAll png files in the screenshots folder

Size, compression and speed

Because artifacts travel from the agent to storage over a network connection, size affects speed. A folder holding twenty thousand tiny files can take far longer to transfer than one compressed bundle of the same total size, since each file carries a little overhead. The simple cure is to compress many small files into a single archive file before the archive step. Compression also saves storage, which helps retention. The trade-off is that a bundle must be unpacked before you can look inside, so keep individual files for small reports that people open in the browser, and use bundles for large collections such as websites or test output folders.

What happens when nothing matches

By default, if the pattern finds no files, Jenkins marks the build as failed, because archiving nothing usually means something went wrong earlier. This is a useful safety net. Sometimes, though, an empty result is normal, such as a screenshot folder that only has files when a test fails. For those cases Jenkins offers an option to allow an empty archive, so the build does not fail just because no screenshots were taken.

i
Tip

Archive in a post-action that runs even when the build fails, if you want failure evidence such as logs and screenshots. If you archive only at the end of a successful path, the most valuable evidence, the files from failed builds, is never saved.

FFinding, Viewing and Downloading Artifacts

Saving files is only half the job. The other half is helping people find the right ones quickly.

On the build page

Open any build that archived files, and the page lists them under a heading for build artifacts. Each file has a link, and there is usually an option to download everything as one compressed bundle. Folders are shown with the same layout the files had in the workspace, so a tidy structure at the time of archiving makes a tidy page later.

The handy permanent links

Jenkins offers stable, ever-fresh links for common needs, called permalinks. Instead of remembering build 57 or build 61, you can use “last build,” “last successful build” or “last stable build,” and Jenkins always points to the newest one of that kind. This makes it easy to share one address that always leads to the latest good package.

PermalinkMeaningBest used for
Last buildThe most recent run, whatever its resultChecking on the very latest state
Last successful buildThe newest build that finished without failureGrabbing the newest usable package
Last stable buildThe newest build that passed with no test problemsTesters who want only clean builds
Last failed buildThe newest build that failedLooking at the newest failure evidence
Everyday Analogy

Think of a library shelf sign that says “Newest arrivals.” The books change every week, but the sign always points to the right shelf. Permalinks are that sign. Your teammates bookmark the sign, not a particular book.

Using artifacts from another job

Often one job builds a package and another job tests or deploys it. The second job needs the first job’s files. There are a few ways to connect them. A popular plugin lets a job copy artifacts from another job’s chosen build, for example “the last successful build of the packaging job.” A more modern and more solid approach is to publish the package to an artifact repository, and have the next job download it from there, by version. This avoids tight coupling between Jenkins jobs and makes the package available to people and systems outside Jenkins too.

i
Tip

Name your artifacts clearly and include a version or build number, for example shop-1.4.57.zip. A plain name such as output.zip forces everyone to guess which one they hold.

SArchive versus Stash: Two Ways to Move Files

Jenkins pipelines have two file-moving tools that sound alike and behave very differently. Mixing them up is one of the most common beginner mistakes.

A pipeline often has several stages, and each stage may run on a different agent. Suppose the build stage compiles code on one machine, and the test stage runs on another. The second machine needs the compiled output. That is a job for stash. A stash takes a set of files from one workspace and holds them temporarily so a later stage can unpack them, on any agent, using unstash.

QuestionArchive artifactsStash and unstash
PurposeKeep files for people and later usePass files between stages of the same build
How long do files last?Until the build or its artifacts are discardedOnly until the end of the build
Who can download them?Anyone with permission, from the build pageNobody directly. Only later stages of that build
Shown on the build page?Yes, with download linksNo
Suitable for large files?Yes, with care about storageOnly small to medium files, since they pass through the controller
Typical usePackages, reports, evidenceCompiled output moved to a test agent
Everyday Analogy

Stash is like handing a folder to a colleague across the office so they can finish the next part of the job. Once the job is done, the folder goes back to the shredder. Archiving is like filing a copy in the company cabinet, where anybody with the right key can open it years later. One is a hand-off, and the other is a record.

A healthy combination

Many good pipelines use both. They stash the compiled output so that parallel test stages on different agents can all use it. At the end, they archive the final package and test reports so people can download them. Stashing keeps the pipeline moving, and archiving preserves the results.

!
Common mix-up

Do not stash a file and expect to download it from the build page afterward. Stashed files vanish when the build ends. If people need to fetch a file, archive it.

PFingerprints: Tracing a File Back to Its Build

A fingerprint lets Jenkins answer a very valuable question: “This file is running in production. Which build made it?”

A fingerprint is a short, unique code that Jenkins calculates from the contents of a file. Two files with the same contents get the same code, and even a tiny change gives a completely different code. When you ask Jenkins to record fingerprints for archived files, it stores each code together with the name of the job and build that produced it.

Later, if you find a file somewhere else, you can give its code to Jenkins and ask, “Have you seen this?” Jenkins can then show you the build that made it, and every other build that used it. This works across jobs too. If a package built in one job was consumed by a test job, and later by a deployment job, the fingerprint links all three, so you can follow the file’s whole journey.

Everyday Analogy

Think of the serial number on an appliance. If a customer calls with a broken toaster, the factory looks up the serial number and finds the day it was made, the batch of parts and the inspector who signed off. A fingerprint is the serial number for a file, and Jenkins is the factory record.

Why teams care

  • Incident response. When a bug appears in production, you can trace the running package back to its exact build and its exact code.
  • Audits. Regulators and customers often ask, “Prove that this release came from your tested pipeline.” Fingerprints and archived files provide that proof.
  • Cleaning up safely. Before deleting an old build, you can see whether a later job still depends on its files.
  • Integrity checks. A matching code shows that a file has not changed since it was built.
i
Tip

Turn on fingerprinting for release-quality artifacts. It costs very little, and it becomes priceless the first time someone asks “Where did this file come from?”

RRetention: How Long Should Artifacts Live?

Artifacts are the heaviest part of a build’s record. Without rules, they quietly consume every last byte of disk.

Every archived file takes space, and busy jobs create new builds constantly. Jenkins provides a build discarder, a rule that deletes old builds automatically. The clever part is that it can treat build records and artifacts separately. You might keep the log and result of the last hundred builds, because they are tiny, but keep the artifacts of only the last ten, because they are large. This gives you a long history of what happened, without a mountain of old packages.

Kind of artifactSuggested keep ruleReason
Everyday development packagesLast few builds, or a few daysNewer builds replace them, so old ones are rarely needed
Test reports and logsKeep for weeks, then move or deleteUseful while investigating, small in size
Failure evidence such as screenshotsKeep for a short timeOnly relevant near the failure
Release candidates and releasesKeep for a long time, ideally in a repositoryNeeded for rollbacks, audits and support
Very large filesStore outside Jenkins, keep only a linkProtects the controller disk

The life of an artifact over time

flowchart LR
    C["Created in workspace"] --> A["Archived with the build"]
    A --> U["Used: downloads and later jobs"]
    U --> R{"Is it a release?"}
    R -->|"Yes"| P["Published to repository and kept long-term"]
    R -->|"No"| D["Discarded by retention rule"]
Figure 3: From creation to long-term storage or cleanup.

Reading the diagram

Every artifact starts life as a file created in the workspace. It is then archived with the build, and for a while it is used: testers download it and later jobs consume it. Then comes a decision point. If the file is a release, it is published to a repository and kept for the long term, because support teams and auditors may need it years from now. If it is an ordinary build output, it is discarded by the retention rule once newer builds have replaced it. Drawing this life story for your own jobs, even on a napkin, is the fastest way to choose sensible retention numbers.

Keeping one build forever

Sometimes a specific build is precious, such as the exact build that produced a public release. Jenkins lets you mark an individual build as “keep this build forever,” which protects it and its artifacts from automatic cleanup. Use this sparingly, since forever is a long time, and consider copying the final package to an artifact repository instead.

Everyday Analogy

Think of a wardrobe. Everyday clothes rotate out every season, and you keep only what you need. But your wedding outfit goes into a special box that you never throw away. The build discarder is the seasonal clear-out. The keep-forever mark is the special box.

!
Warning

Jenkins is a working record, not a permanent archive. Never make it the only home for a file you must keep for years. Important releases belong in a proper artifact repository with its own backups and rules.

Measuring the problem

To keep disk use under control, look at the size of each job’s artifacts, and multiply by the number of builds you keep. That simple multiplication often reveals a surprise, such as one job using half the disk. Trimming that single job, by archiving fewer files or discarding sooner, may solve the whole problem.

EExternal Storage and Artifact Repositories

As teams grow, the controller’s disk stops being a good place for packages. Specialized storage takes over.

An artifact repository is a system built specifically to store and serve packages. It gives each package a name and a version, keeps every version, lets other tools download by version, and often adds features like access control, cleanup rules and security scanning. Well-known products exist for this purpose, and cloud providers offer storage services that can play the same role.

flowchart LR
    B["Jenkins Build"] -->|"publish package with version"| R["Artifact Repository"]
    B -->|"reports and logs"| J["Jenkins Build Page"]
    R --> T["Test Job"]
    R --> S["Staging Deployment"]
    R --> P["Production Deployment"]
    R --> U["Other Teams and Tools"]
Figure 2: A build publishes its package to a repository, while reports stay on the build page.

Reading the diagram

The build produces two kinds of output. The versioned package goes to the artifact repository, where every later step downloads it by version: the test job, the staging deployment, the production deployment and even other teams. The lighter reports and logs stay on the Jenkins build page, next to the run that created them. This split keeps the controller light while making the package available to everyone who needs it.

Why this pattern is popular

  • The controller stays healthy. Large files never fill its disk.
  • Versions are first-class. Everyone refers to “version 1.4.57” instead of “the last successful build of job X.”
  • Everything downstream uses the same file. The package that was tested is exactly the package that is deployed, which is the golden rule of delivery: build once and promote the same artifact.
  • Access can be tailored. The repository can give production systems read access without giving them any access to Jenkins.
  • Lifecycle rules are richer. Snapshots can expire quickly while releases are kept for years.

Cloud storage plugins

There are Jenkins plugins that send archived artifacts to cloud object storage instead of the controller’s disk. From the user’s point of view nothing changes: the build page still lists files and offers downloads. Behind the scenes, the files live in the cloud, which gives more room and cheaper long-term storage. This is a good middle path for teams that want to keep using the built-in archive feature without risking the controller disk.

i
Tip

A good split of duties is this: repositories hold packages that other systems consume, and the Jenkins archive holds evidence about the build, such as reports, logs and screenshots.

WWhere You Set It Up: Web Forms and Pipelines

Archiving can be turned on from a web form or from a pipeline recipe. Both do the same thing.

In a classic job

In a freestyle job, open the job’s configuration page and add a post-build action named for archiving artifacts. A box appears where you type the file pattern. Further options let you exclude patterns, allow an empty archive, archive only when the build succeeds, record fingerprints, and choose whether to keep only the latest build’s artifacts. Save the job, and every future build will archive matching files.

In a pipeline job

In a pipeline, archiving is a step placed in a stage or in the closing section. The step takes the same kinds of choices: the file pattern, exclusions, whether an empty result is allowed, and whether to record fingerprints. Placing it in the closing section that always runs means failure evidence is still saved when the build fails. Because the pipeline recipe lives beside the code, the archive rules are reviewed and versioned like any other change.

Everyday Analogy

Setting the archive rule on a web form is like a sticky note on one office computer saying “save the reports.” Writing it in the pipeline file is like putting the rule in the staff handbook. Everyone sees it, it has a history, and it is not lost when a computer is replaced.

Choices worth understanding

OptionWhat it doesWhen to use it
Files to archiveSets the file pattern that picks filesAlways. Make it specific
ExcludesRemoves some matches from the selectionTo skip bulky logs or temporary files
Allow empty archiveStops the build failing if nothing matchesWhen files only appear in some cases
Only if build is successfulArchives nothing when the build failsFor packages, not for failure evidence
Fingerprint all archived artifactsRecords a unique code for each fileFor releases and anything that may need tracing
Keep only the latest artifactsDeletes artifacts of older builds as new ones arriveFor jobs where only the newest package matters

A worked example: planning archiving for one small team

Imagine a team of six building a web shop. Their pipeline compiles the site, runs tests, and produces a zipped copy of the website. Here is how they might plan their archiving, in words. The zipped website is named with the version and build number, so every copy is easy to tell apart, and it is archived with fingerprints turned on. The test report files are archived from every build, because they are small and useful for spotting trends. Screenshots from the browser tests are archived only when tests fail, in a closing section that always runs, and the option to allow an empty archive is switched on, since a passing run has no screenshots at all.

For retention, they keep the build records and logs of the last two hundred builds, keep the zipped website for the last fifteen builds only, and delete screenshots after two weeks. When a version is approved for release, the pipeline publishes that exact zip file to a repository, and the Jenkins copy is allowed to expire normally. Notice what this plan achieves. Nothing valuable is lost, disk use stays predictable, every file is traceable, and nobody has to remember a manual step.

i
Tip

Start with a narrow pattern and widen it only when needed. It is much easier to add a missing file than to clean up gigabytes of accidental junk.

SSecurity Around Artifacts

Artifacts often contain valuable or sensitive things. Who can see them, and what is inside them, both matter.

Everyday Analogy

Think of a records room. Some cabinets hold public leaflets and anyone may take one. Others hold confidential contracts and need a key. Nobody would put a customer’s private letter in the public leaflet rack by mistake. The same care applies when deciding what to archive and who may open it.

RiskWhy it mattersHow to reduce it
Secrets inside archived filesConfig files, logs or dumps may contain passwords and tokens that anyone with access can then readNever archive files with secrets, scrub logs, and use the credentials store
Too many people can downloadConfidential builds could be copied freelyUse permissions so only the right roles can view or download artifacts
Tampered filesA changed package could reach productionRecord fingerprints, and sign or checksum release files
Untrusted builds archiving anythingStrangers’ code might upload harmful files or fill the diskBuild outside contributions on isolated agents, with small limits
Viewing files in the browserAn archived web page with scripts could try to attack a viewerKeep Jenkins’ default protective settings, and download such files instead of opening them
Endless retention of sensitive dataOld reports may hold customer informationSet retention rules, and delete what is no longer needed

Permissions

Jenkins can control who may see a job, who may view its builds, and who may download artifacts. A common setup lets all developers view and download from ordinary jobs, while restricting release jobs to a smaller group. Follow least privilege, meaning each person gets only the access their work needs.

!
Warning

Before archiving a folder, look inside it. Crash dumps, environment listings and verbose debug logs are the most common places where secrets leak into artifacts. A single forgotten token in an archived file can outlive every rotation you perform elsewhere.

MMonitoring, Logging and Metrics

Artifacts quietly grow every day. A few simple measurements keep that growth from becoming an emergency.

Everyday Analogy

A water tank has a gauge on the side. Nobody stares at it all day, but everybody notices when it drops low. Disk space is Jenkins’ water tank, and artifacts are the taps that keep running. You want a gauge and an alarm.

What to watchWhat it tells youTypical action
Free disk space on the controllerHow close you are to troubleAlert early, tighten retention
Artifact size per jobWhich jobs use the most spaceTrim patterns or move large files out
Growth per weekWhether space use is steady or acceleratingPlan capacity before it runs out
Archive step durationHow long transfers takeCompress files, reduce size, or use nearby storage
Archive failuresMissing files or pattern mistakesFix patterns and earlier steps
Download errorsBroken links after cleanupAlign cleanup rules with what teams still need

Logs that help

The build’s console log says which files were archived and how many. If a build “succeeded” but the expected package is missing from the page, this line is the first place to look. Good pipelines also print a short summary just before archiving, such as the names and sizes of the files about to be saved. That habit makes surprises visible at once.

Metrics tools

Jenkins can publish numbers about itself through plugins for popular monitoring systems. A common setup lets Prometheus, a widely used metrics collector, gather disk and build figures, while Grafana draws charts and raises alerts. Set alarms on symptoms that matter, such as disk usage passing a limit, not on every tiny twitch.

i
Tip

Set the disk alarm at a comfortable level, such as seventy or eighty percent, so there is time to react. An alarm at ninety-nine percent is only an announcement of the outage.

AAdvantages, Disadvantages and Trade-offs

Archiving is simple and powerful. It also has costs that grow quietly, so it pays to know both sides.

Advantages

  • Every build keeps its own output, so any version can be fetched again
  • Very easy to enable, with no extra system needed
  • Files are linked to the build that made them, giving clear traceability
  • Fingerprints connect a file to its origin across jobs
  • Failure evidence such as logs and screenshots survives the workspace
  • Permalinks give stable addresses for the latest good build
  • Works with any file type from any tool

Disadvantages

  • Default storage uses the controller’s disk, which can fill quickly
  • Large transfers from agents can slow builds
  • Version handling is by build number, not by proper package version
  • Not a full package manager, so other tools cannot easily consume it
  • Poor patterns can archive junk and secrets by accident
  • Old artifacts need careful retention rules or they pile up

Trade-offs to think about

Simple vs scalable

Built-in archive or repository

The built-in archive needs nothing extra. Repositories scale better and add versioning. Many teams start simple and move up.

More vs less

How much to keep

Keeping more helps investigations but costs space. Keep evidence briefly and releases for long.

Speed vs completeness

What to archive

Archiving everything is easy but slow and heavy. A careful pattern is quicker and cleaner.

Compressed vs loose

File form

One compressed bundle transfers faster than thousands of small files, but is harder to browse.

Open vs restricted

Who may download

Open access is convenient, and restricted access is safer for confidential builds.

Success vs always

When to archive

Archiving only on success saves space. Archiving always saves failure evidence.

PDesign Patterns and Anti-patterns

A pattern is a proven way to solve a common problem. An anti-pattern is a habit that looks helpful and causes pain later.

Patterns worth copying

Pattern

Build once, promote

Create one package, archive or publish it, and move that exact file through every environment.

Pattern

Package to repository, evidence to Jenkins

Send versioned packages to a repository, and keep reports and logs on the build page.

Pattern

Archive in a closing section

Save logs and screenshots even when the build fails.

Pattern

Versioned file names

Include the version or build number so nobody has to guess.

Pattern

Fingerprint releases

Record fingerprints so any deployed file can be traced.

Pattern

Separate retention

Keep build records for a long time and artifacts for a short time, with special rules for releases.

Pattern

Compress before archiving

Bundle many small files into one, so transfers are quick and storage is tidy.

Habits to avoid

ANTI-PATTERN 01Avoid
What it looks like

The archive pattern says “everything in the workspace,” so every build saves downloaded tools, source code copies and temporary folders.

Why it hurts

Each build uses gigabytes, the controller disk fills, and useful files are lost in a sea of clutter.

Do this instead

List only the files that people truly need, and exclude bulky or temporary ones.

ANTI-PATTERN 02Avoid
What it looks like

Jenkins is used as the permanent warehouse for release packages, with years of files kept only on the controller.

Why it hurts

One disk failure, one careless cleanup or one lost server, and every release ever shipped is gone. Nobody else can fetch them by version either.

Do this instead

Publish releases to an artifact repository with proper backups and lifecycle rules.

ANTI-PATTERN 03Avoid
What it looks like

The team rebuilds the code separately for testing, staging and production, so three different files are made from the same source.

Why it hurts

The file that was tested is not the file that shipped. A tiny difference in tools or timing can cause a bug that no test ever saw.

Do this instead

Build once, save that single artifact, and promote the same file through each environment.

ANTI-PATTERN 04Avoid
What it looks like

Files with the same name, such as output.zip, are archived by every build, and testers ask, “Which output.zip is this?”

Why it hurts

Downloaded copies get mixed up outside Jenkins, and nobody can tell which build a file came from.

Do this instead

Put a version or build number in every file name, and record fingerprints.

ANTI-PATTERN 05Avoid
What it looks like

A debug log containing a password is archived for every build, and it can be downloaded by everyone in the company.

Why it hurts

A secret leaks to many people, and it stays in old builds long after it has been rotated in other places.

Do this instead

Keep secrets out of logs, review what you archive, restrict access and set short retention for sensitive files.

BBest Practices and Common Mistakes

These are lessons that experienced teams usually learn the hard way. You can learn them the easy way, by reading them now.

Best practices

  • Archive only what people need. Use specific patterns and exclusions.
  • Archive failure evidence too. Put logs and screenshots in a closing section that always runs.
  • Name files with versions. A version or build number in the file name prevents confusion.
  • Fingerprint releases. Make every deployed file traceable to its build.
  • Publish packages to a repository. Keep Jenkins for evidence and short-term needs.
  • Set retention on day one. Decide how many builds and how many days of artifacts to keep, before the disk fills.
  • Use different rules for different files. Short for bulky artifacts, longer for logs, longest for releases.
  • Compress many small files. One bundle is faster to move and easier to store.
  • Print what you archive. A short listing in the log makes surprises visible.
  • Watch disk space. Set alarms early and check which jobs use the most.
  • Protect sensitive files. Review contents, restrict downloads and shorten retention.

Common mistakes

  • Archiving nothing at all. Then no one can retrieve last week’s version.
  • Archiving the whole workspace. It fills the disk with clutter.
  • Confusing stash with archive. Stashed files disappear when the build ends.
  • Trusting Jenkins as the permanent archive. It is a working record, not a vault.
  • Forgetting the empty-archive option. Builds fail only because an optional folder was empty.
  • Ignoring failed builds. The most valuable evidence is exactly what a failed build produces.
  • Leaving secrets in archived files. They stay downloadable for as long as the build is kept.
  • Never checking sizes. One growing report can quietly use half the disk.
i
Tip

Pick one job and make its archiving excellent: a narrow pattern, versioned names, fingerprints, sensible retention and a clean listing in the log. Then copy that job’s approach to the others. A good example spreads faster than a long rulebook.

TTroubleshooting: When Artifacts Go Missing or Grow Wild

Sooner or later, an expected file is not on the build page, or the disk is suddenly full. A calm routine finds the cause quickly.

A simple routine for a missing artifact

1

Check the console log

Look near the end for the archive step. It usually says how many files were saved, or that none matched.

2

Check the file pattern

Compare the pattern with the real folder layout in the workspace. A wrong folder name or a missing double star is the most common cause.

3

Check where the file was created

Was it written inside the workspace? Files created elsewhere on the machine cannot be archived until they are copied in.

4

Check the archive conditions

Was archiving set to run only on success, while the build failed? Did an earlier stage stop the pipeline before the archive step?

5

Check retention

The file may have been archived and then deleted by a discarder rule. Compare the build’s age with the rule.

Common situations and their usual causes

SymptomLikely causeWhat to check
Build fails with “no artifacts found”Pattern matches nothingPattern, folder names, whether the earlier step created the file
Artifact list is empty on a failed buildArchiving runs only after successMove it into a closing section that always runs
Old builds have no artifactsRetention deleted themDiscarder rules for artifacts
Controller disk is nearly fullLarge artifacts kept for many buildsSize per job, retention, external storage
Archive step is very slowMany small files or a very large file over a slow linkCompress into one file, reduce size, check network
Downstream job cannot find the fileWrong build selected, or artifact discardedWhich build the copy step points to, retention
Stashed files are gone after the buildStash is temporaryArchive the files if people need them
Same file name confuses testersNo version in the nameAdd version or build number, record fingerprints
i
Tip

When a file is missing, look in the workspace first. If the file is not there at the moment of archiving, no pattern in the world will find it. Fix the step that should have created it.

RReal-World and Industry Examples

Archiving artifacts looks small, yet nearly every serious engineering team depends on it. Here is how the ideas appear in practice.

Mobile app teams

Every build of a phone app produces an installable file. Teams archive it, and testers download the latest version straight from the build page onto their devices. When a bug appears, they can fetch the exact build from last Thursday to compare behavior.

Large engineering organizations

Companies with thousands of developers usually send versioned packages to a dedicated repository, and keep test evidence in Jenkins. The repository serves hundreds of other systems, while Jenkins stays lean and fast.

Open-source projects

Many projects publish nightly downloads, packages created from the latest code. Users try them and report problems before the official release. Archived artifacts are the download links behind those nightly builds.

Regulated industries

Banks, hospitals and telecom providers often must prove that a released file came from a controlled, tested pipeline. Archived packages, test reports and fingerprints together form that evidence, and auditors can inspect them long after the release.

User-interface testing teams

When an automated browser test fails, a screenshot or recording of the moment is worth a thousand log lines. Teams archive these files for failed builds only, keep them for a couple of weeks, and then let cleanup remove them.

Small teams and startups

A small team may simply archive the zipped website from each build and keep the last twenty. When a release goes wrong, they redeploy the previous archived build in minutes. That single habit replaces a great deal of stress.

Lessons that repeat across teams

Look across these examples and a few lessons appear again and again. Successful teams treat build outputs as valuable records, not as leftovers. They save only what people need, and they name it clearly. They separate short-lived evidence from long-lived releases, and they store each in the right place. They record fingerprints so that any running file can be traced. And they watch disk space long before it becomes a crisis. None of this needs a large budget. A small team can follow every one of these habits from the very first week.

Habits of teams that never lose a file

Teams that rarely get burned by missing artifacts share a few quiet habits. They write down, for every job, what it archives, where the file goes next and how long it lives, often in a single short page that anyone can read. They test their recovery path now and then, by picking an old release at random and making sure it can still be found and downloaded. They review the biggest jobs once a month, because storage problems grow slowly and then arrive suddenly. And they treat a change to an archive rule like a change to code: someone reviews it, and the reason is written down. These habits cost very little time, and they turn artifacts from a hidden risk into a reliable safety net that the whole team trusts.

A build that leaves nothing behind can never be repeated, inspected or trusted. Archiving is how a build keeps its promises.

FFrequently Asked Questions

Q1What is archiving artifacts, in the simplest words?
It is telling Jenkins to keep chosen files from a build and attach them to that build, so they can be downloaded later even after the workspace is cleaned.
Q2What counts as an artifact?
Any file a build produces that you want to keep, such as packages, reports, logs, screenshots or measurement files.
Q3Where does Jenkins store archived artifacts by default?
On the controller’s disk, inside the Jenkins home folder, in a directory that belongs to the specific build. Plugins can send them to other storage instead.
Q4What is the difference between archive and stash?
Archive keeps files for people to download and lasts until the build or its artifacts are discarded. Stash only passes files between stages of one build and disappears when the build ends.
Q5Why did my build fail with a message about no artifacts?
Because the file pattern matched no files. Check the pattern against the real folder layout, and check that an earlier step actually created the files. If empty results are normal, allow an empty archive.
Q6Can I archive artifacts from a failed build?
Yes, if the archive step runs even after failure, for example in a closing section that always runs. This is the best way to keep logs and screenshots for failed builds.
Q7What is a fingerprint?
A unique code calculated from a file’s contents. Jenkins stores it with the build that made the file, so you can later find out where a file came from.
Q8How long does Jenkins keep artifacts?
Only as long as your retention rules allow. Without rules, it may keep everything, which slowly fills the disk. A build can also be marked to keep forever.
Q9Should I use Jenkins as my permanent release storage?
It is better not to. Jenkins is a working record. Put releases in an artifact repository with proper backups, versioning and lifecycle rules.
Q10How can another job use artifacts from this job?
Through a plugin that copies artifacts from a chosen build, or, more robustly, by publishing the package to a repository and letting the other job download it by version.
Q11How do I get the newest good package with one link?
Use a permalink such as last successful build or last stable build. It always points to the newest matching build, so the link never needs updating.
Q12Can I archive files that are outside the workspace?
Not directly. Copy them into the workspace first, then archive them.
Q13How do I stop artifacts from filling the disk?
Archive only what is needed, set a build discarder that removes artifacts sooner than logs, compress files, move large packages to a repository or cloud storage, and watch disk space with alarms.
Q14Is it safe to archive log files?
Only if the logs contain no secrets. Review what is inside, restrict who can download, and set short retention for sensitive material.
Q15Does archiving slow down my build?
A little, because files must travel from the agent to storage. The time is small for a few reports and larger for big packages or thousands of tiny files. Compressing files into one bundle usually makes the step much faster.
Q16Can I download all artifacts of a build at once?
Yes. The build page normally offers a single download of everything as one compressed bundle, as well as a link for each individual file.
Q17Do artifacts keep their folder structure?
Yes. Files are stored with the same relative folder layout they had in the workspace, so a tidy structure at archive time gives a tidy page later.

SSummary and Key Takeaways

Archiving artifacts is how a Jenkins build carries its results out of the kitchen before the cleaning crew arrives.

Key Takeaways

  • What it is: Archiving copies chosen files from a build’s temporary workspace into storage and attaches them to that build, so they can be downloaded later.
  • How it works: A file pattern picks files, Jenkins transfers them from the agent, stores them under the build record, and optionally records fingerprints. Be specific, or junk will fill the disk.
  • Archive is not stash: Archive keeps files for people and lasts until cleanup. Stash only hands files between stages of one build and vanishes at the end.
  • Trace and find: Fingerprints connect any file back to its build, and permalinks such as last successful build give one stable link to the newest good package.
  • Retention matters: Artifacts are the heaviest part of a build. Set discarder rules early, keep evidence briefly and releases longer, and use keep-forever sparingly.
  • Use the right home: The controller’s disk is fine for reports and small files. Send versioned packages to an artifact repository or cloud storage, and build once and promote the same file.
  • Stay safe: Never archive secrets, restrict who can download, watch disk space, and archive failure evidence in a closing section that always runs.