Deleting Maven (.m2) and general cache locations used by Bamboo
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This knowledge base article guides how to delete the contents of Maven and general cache locations on a Bamboo Server or Agent. These directories are used by Maven and various other applications, respectively, to store local artifacts, cache data, and other temporary files. Over time, these locations can accumulate significant data, leading to excessive disk usage.
You may see cache
and .m2
directories on different operating systems:
Operating system | .m2 directory | cache directory |
---|---|---|
Windows | C:\Users\<username>\.m2\repository | C:\Users\<username>\AppData\Local |
Linux | /home/<username>/.m2/repository | /home/<username>/.cache |
Mac | /Users/<username>/.m2/repository | /Users/<username>/.cache |
Environment
Bamboo Server or Data Center
Bamboo Agents (Remote/Elastic/Ephemeral)
Diagnosis
<bamboo-user-homedir>/.m2/repository
This local repository for Maven stores downloaded and locally built artifacts. Over time, this directory can become very large.
<bamboo-user-homedir>/.cache or
<bamboo-user-homedir>\AppData\Local
Various applications use this generic location to store cached data. Users could diagnose by noticing the increase in disk space usage.
Cause
There are multiple causes of a large .m2
location:
Multiple projects:
Working on multiple Maven projects causes more artifacts to be stored in the
.m2
location
Large dependencies:
Some projects may have particularly large dependencies, contributing significantly to the size of the
.m2
location
Old or unused artifacts:
Over time, artifacts that are no longer needed (for example, from old projects or previous versions of dependencies) accumulate in the
.m2
location
There is a leading cause of the large general cache
location:
Multiple application caches:
Over time, the cache folder can accumulate many temporary and cached data from various applications, leading to excessive disk usage. This can cause problems, especially in environments with limited disk space.
Solution
When you run builds on Bamboo using Local, Remote, Elastic, or Ephemeral Agents employing Maven, the repository cache locations can be filled up after each execution. Every development team is responsible for being aware of their build dependencies and striving to make the most efficient use of the filesystem. In some situations, increasing disk space or adjusting Maven's configurations to store the files in a different repository cache spot can address disk space issues.
The reported locations are not exclusive to the Bamboo server and may also be found on the Agents. Check both Server and Agent environments and proceed with the data purge when necessary.
Delete the contents of <bamboo-user-homedir>
/
.m2/repository
:
Stop any running Maven builds or other processes that may be using the
.m2/repository
location.Make a backup of any critical data in the
.m2/repository
location.Delete the
.m2/repository
contents (but not the location)Rerun Maven builds.
Delete the contents of <bamboo-user-homedir>/.cache
or <bamboo-user-homedir>\AppData\Local
Close all running applications that may be using the cache location. In some environments, you may have to contact your System Administrator to confirm it.
Back up any critical data from the cache location
Delete the cache location contents (but not the location).
Was this helpful?