A clean Bamboo build directory is one your next build can trust. To maintain one, decide which paths are disposable, clear the right directory before each plan or deployment, and let Bamboo's own expiry and plan settings remove old artifacts on a schedule. The key condition is scope: wiping a working directory is safe and routine, while deleting the wrong items under Bamboo's home can erase history, configuration, or artifacts your teams still need. This guide separates those cases.

If you run Bamboo Server or Data Center and your agents' disks keep filling with workspaces, old artifacts, and stray build outputs, the fix isn't one heroic cleanup. It's a small, repeatable routine built into plan configuration and agent housekeeping. Most mess comes from three places: per-plan working directories that accumulate build output, the artifact store under Bamboo's home, and local caches that individual builds write next to the workspace. Each has its own safe cleaning method, and mixing them up is how people delete things they needed.

I've organized this around the directory types first, because almost every mistake in this area is a scope mistake: someone deletes what looked like a cache and turns out to be shared configuration.

Know which Bamboo directories you're actually cleaning

Bamboo keeps files in a few broad locations on the server or remote agent, and Atlassian's documentation makes the practical distinction clear: some directories are regenerable and some are not.

Working directory (workspace): the per-plan, per-agent checkout area where source is pulled and builds run. Wiping it is normal. Bamboo re-creates and re-checks out on the next build. Build output and build data: produced during a build, such as compiled binaries, test reports, and logs. Old output is clutter unless a later plan step or downstream plan depends on it. Artifacts: published by a job and stored in Bamboo's artifact storage, consumable by other plans or deployments. These are the outputs with the longest life and the biggest disk footprint. Bamboo home configuration: plans, global settings, user data, and the database connection. This is not disposable. You back it up; you don't clear it.

The exact absolute paths depend on your operating system and how the agent is installed, so don't guess them from memory in a production change. The reliable method is to read them off the running instance: Bamboo shows the working directory and build directory for each plan on the plan's configuration and its build results, and agent administration shows the agent's home and working directories. Record those paths for your server and agents once, and keep the list where operators can see it.

The safe rule that follows: cleanup commands should only ever target directories you've confirmed are working directories, build outputs, or artifacts you've chosen to expire. Never aim a broad delete at a parent folder that also contains configuration.

Prerequisites before you touch anything

Set these up before the first cleanup, because they're what turns a risky manual habit into a maintainable routine.

1: Write down each path and its role. Note the server's Bamboo home, each agent's working directory, and the artifact location. Mark which are regenerable. 2: Confirm your backup posture for Bamboo home and the database. Atlassian's standard backup guidance covers the home directory and database together, and cleanup changes under Bamboo home should be preceded by a verified backup you've tested restoring. Treat backup verification as a real step, not a checkbox. 3: Get agent access. Working-directory cleanup usually happens on the agent host, as the OS user that runs the agent. Confirm you can log in as that user or elevate to it, and that you know which agents are remote versus local to the server. 4: Set a maintenance window or choose off-peak timing. Cleaning a working directory mid-build causes a failure. Use Bamboo's plan activity view or the build queue to confirm nothing is running against the plan you're targeting. 5: Know who owns the plan. Changes to artifact expiry or plan variables affect downstream plans and deployments. A quick check with the plan owner prevents surprises.

Once those exist, period cleanup becomes a checklist rather than an improvisation.

Clean a working directory safely, step by step

This covers the common case: a plan's checkout has grown large, or a build is showing stale checked-out files.

1: Identify the exact working directory. In Bamboo, open the plan's configuration and find the working directory path for the relevant agent, or use agent administration to see the agent's working directory root and the per-plan subfolder. Note the full path. 2: Verify no build is running. Check the plan's build activity and the queue. If a build is queued or running for that plan on that agent, wait or stop it intentionally first. 3: Confirm the path is the plan's working directory, not a shared parent. List the directory contents before deleting. If you see Bamboo configuration files or source for a different plan, you have the wrong target. Back up one level and re-check. 4: Delete the contents of the plan's working directory, not the parent folder. On the agent host, that's a removal of the files and subfolders inside the confirmed workspace path. Keep the working directory root itself and any per-agent structure Bamboo expects. 5: Run a build to confirm recovery. Queuing a manual build forces a fresh checkout. A successful build with a clean checkout log line is your success check.

Failure signs and what they mean: a build fails at checkout with permission errors usually means the cleanup was run by a different OS user than the agent, leaving files the agent can't modify. Restore correct ownership rather than deleting again. A build that can't find a directory usually means you deleted something Bamboo expected to exist, such as the working directory root rather than its contents.

Clear build output and build data with correct scope

Build output and intermediate data sit inside the working directory, which is why a working-directory wipe is often the simplest way to clear them. If you want a narrower cleanup, target specific output folders your build scripts create, such as a target, build, dist, or coverage directory.

The decision for any given folder is dependency, not age. Ask: does another plan or deployment consume this path as an artifact, or does a later step in the same job read it? If yes, it's an output you must preserve or replace with artifact publishing, not delete blindly. If no, it's regenerable clutter.

For cleaning a subset:

1: Confirm the folder is created by the build and isn't tracked source. Check the build script for the output path it writes. 2: Confirm no job step later in the same plan reads that folder from a previous run; Bamboo builds should not depend on leftover state from an earlier build, but some scripts do. 3: Delete only the confirmed output subfolder inside the working directory. 4: Re-run the plan and confirm it regenerates the output from scratch.

The one thing to avoid is relying on cleanup to fix non-reproducible builds. If a plan only passes because leftover files survive between runs, the real fix is making that step produce its output reliably, not scheduling more frequent deletes.

Control the artifact store so it doesn't balloon

Artifacts are the long-lived outputs, so expiry is the main lever. Bamboo's artifact expiry rules let you define, per plan, how long to keep artifacts and which ones to keep, and you can set multiple rules so different artifact sets follow different retention. Plan-level expiry settings also define how artifact cleanup behaves for that plan.

A workable policy structure:

Short retention for disposable artifacts: test reports, screenshots, and logs you only need for recent builds. Expire these aggressively. Longer retention for release or deployment inputs: artifacts that downstream deployment projects consume. These need to outlive the deployment window. Never-expire only for genuine records: artifacts with compliance or audit meaning. Keep this list short and justified; "we might need it" is how the store grows without bound.

Before tightening expiry, check for consumers. Artifact dependencies and deployment projects read artifacts by plan and build. The agent-side surface for this is Bamboo's artifact handling, but the operational risk is human: a deployment that pulls "latest successful artifact" will break if you expire the artifact that a still-pending deployment expects. Coordinate expiry changes with the teams that run those deployments.

The success check is measurable: record the artifact store size and the number of plans with at least one expiry rule, before and after. If size keeps growing while rules are in place, the rules are probably too permissive or some plans have no rules at all. Bamboo's own artefact expiry and cleanup documentation (see your version's docs, since the settings and screens are version-specific) is the authoritative reference for exactly which fields you set and how the cleanup behaves.

Use Bamboo's built-in cleanup and expiry features instead of ad-hoc deletes

The durable solution is to let Bamboo manage the mess. The settings that matter, described by function rather than by exact menu location because screens vary by version:

Plan-level artifact expiry: per-plan rules that delete artifacts after a period or keep only recent builds. Build result and log retention: how long build records and logs persist. Longer retention means more stored data, so it interacts with disk planning. Plan and agent working-directory cleanup: settings on agents and plans that control whether leftover working directories are kept around. Bamboo's own cleanup options may remove old working directories on certain patterns; confirm what your version supports in agent and plan configuration. Scheduled maintenance and housekeeping jobs: the server-side or scheduled tasks that prune old data.

A reliable schedule looks like this: daily, let Bamboo's scheduled cleanup run; weekly, review agents' free disk and any alerts; quarterly, audit which plans have expiry rules and whether any store is growing faster than its consumers justify. That cadence catches a runaway artifact before it fills the disk, and it keeps the configuration honest.

Do not automate a disk-wide script that deletes "old-looking" Bamboo files. The failure mode is a scheduled task that removes something the running instance depends on, and those failures surface at the worst times. Scheduled deletion should be expressed in Bamboo's own settings, where the scope is defined by the product rather than by a wildcard.

Keep agents and local caches tidy with a repeatable routine

Remote agents are where most disk pressure shows up, because they can run many plans and each plan has its own working directory. A single agent host can accumulate workspaces for every plan it has executed.

A practical routine for each agent host:

1: List working directories per plan and note their sizes. You can do this at the OS level once you know the agent's working directory root, and you can correlate with which plans run on that agent. 2: Set agent-level retentions where Bamboo supports them, so old working directories don't sit forever. If your agent configuration exposes working-directory cleanup settings, prefer them over manual deletes because they're bounded by Bamboo's own logic. 3: Clean only stale directories for plans no longer running on that agent. If an agent previously handled a plan and no longer does, its leftover workspace for that plan is a candidate, but confirm the plan isn't still using the agent during a fallback or failover. 4: Document the cleanup command per OS with a fixed, quoted path. On a Linux agent, a delete should target an absolute path you've verified; the same discipline applies on Windows. An unquoted or wildcard-expanded path is the classic way to delete more than intended.

A useful edge case: shared build caches. Builds sometimes use external caches, such as dependency caches or build caches in tools like Gradle or Maven. Clearing these on the agent is safe and can reset a corrupted cache, but clearing them on a host that serves multiple plans can temporarily slow every build that shares them. Schedule cache resets around that cost and be explicit in the agent documentation about which caches are per-agent versus shared.

The success check for the agent routine is boring but effective: after a cleanup and a few subsequent builds, no plan fails at checkout, build times are stable, and free disk is above your alert threshold.

Detect and fix the usual failure modes

The symptoms map to a few causes, and the first check for each is reversible.

Build fails with "cannot create directory" or "file exists" errors after cleanup. Likely cause: leftover files owned by a different OS user, or a partial delete. Check ownership first and fix it rather than deleting again. Builds keep failing because a source file was modified in the workspace. Likely cause: someone edited checked-out files directly. A clean working-directory wipe restores the checkout; the deeper fix is to stop manual edits inside workspaces. The artifact store keeps growing despite expiry rules. Likely cause: plans without rules, or rules that keep too much. Audit for plans with no expiry and tighten the most permissive rules. Deployments fail after a cleanup. Likely cause: you expired artifacts a deployment still needed. Restore from your artifact backup if available, and coordinate retention with deployment owners next time. The server disk drops quickly right after cleanup. Likely cause: something is still writing in the background, such as logs or a scheduled task. Check the server's free-disk trend and any growing files.

Stop condition: if you've touched anything under Bamboo home (configuration, database, or the server's data directories) and the instance isn't behaving correctly, stop making further changes. Restore from your verified backup and involve experienced Bamboo administration support or Atlassian support before attempting more. Fixing a server configuration problem with more deletions is how a small mistake becomes an outage.

Run cleanup as a scheduled, auditable routine

The difference between a clean Bamboo installation and one that constantly fights for disk is usually not one setting. It's whether the cleanup is a routine with owners, backups, and checks.

A simple cadence I'd recommend:

Daily: automated Bamboo housekeeping and scheduled cleanup run unattended. Weekly: check disk usage on the server and each agent, and confirm the free-space alert threshold is intact. Monthly: spot-check one plan's working directory and its artifact list against the intended policy. Quarterly: review every plan's expiry rules and document changes.

A short record of each cleanup, with the path targeted, the reason, and the result of the follow-up build, is your audit trail. If a plan later fails unexpectedly, you can compare its timeline against cleanup activity and rule it out quickly.

That routine also protects you from the most expensive version of this problem: the team that cleans aggressively during a crisis, then turns off all expiry because something broke. Consistent, narrowly scoped cleanup keeps the whole Bamboo estate predictable, leaves room for legitimate long-lived artifacts, and makes future disk pressure an early warning instead of an emergency.

FAQ

Is it safe to delete an entire Bamboo working directory? Yes, in normal operation a plan's working directory is disposable: Bamboo checks out again on the next build. The safety conditions are that it's the plan's own workspace, no build is running, and you delete its contents rather than a parent folder that holds other plans or agent configuration.

Will expiring artifacts break a deployment? It can, if the deployment reads artifacts from the builds you expire. Check the plan's artifact dependencies and any deployment projects that consume its artifacts before shortening retention, and coordinate the change with the teams running those deployments.

What should never be part of routine cleanup? Anything in Bamboo home that holds configuration or data, the database, and any directory whose role you haven't confirmed. Back up Bamboo home and the database before changes that touch them, and be specific about which cleanup operations are excluded from routine tasks.

How do I know the cleanup is actually working? Use the follow-up build as the check: a fresh checkout should succeed and regenerate build output. Then track the numbers over time, such as free disk on agents and artifact store size, so you can see whether the cleanup is keeping up with growth rather than just moving the problem.