Deleting Maven (.m2) and general cache locations used by Bamboo

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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 directorycache directory

Windows

C:\Users\<username>\.m2\repositoryC:\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 :

  1. Stop any running Maven builds or other processes that may be using the .m2/repository location.
  2. Make a backup of any critical data in the .m2/repository location.
  3. Delete the .m2/repository contents (but not the location)
  4. Rerun Maven builds.

Delete the contents of <bamboo-user-homedir>/.cache or <bamboo-user-homedir>\AppData\Local

  1. 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.

  2. Back up any critical data from the cache location

  3. Delete the cache location contents (but not the location).



Last modified on Sep 7, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.