How to clear Maven cache

Article ID:360055200412
1 minute readKnowledge base

Issue

My Maven cache is growing and I need to clear it out. How can I delete/clear my Maven cache?

Resolution

Local Maven Repository location

When a Maven build is executed, Maven automatically downloads all the dependency jars into the local repository. Usually this folder is named .m2/repository.

  • To clear/delete your local maven repository cache, simply delete the .m2/repository folder.

  • You can find the default Local Maven Repository for each operating system below:

    Operating System Local Maven Repository

    Linux

    /home/<User_Name>/.m2

    MacOS

    /Users/<User_name>/.m2

    Windows

    C:\Users\<User_Name>\.m2

  • Additionally, if you are using the Maven Integration plugin you can find the Local Maven Repository inside the Jenkins UI by going to Manage Jenkins > Configure System > Local Maven Repository under Maven Project Configuration

    How_to_clean_up_Maven_cache/local_maven_repository.png
  • The local repository path can also be configured in Maven setting.xml (either the global or the user one). See Maven documentation for more details.

  • Finally the local repository path can be overridden by the Maven Pipeline plugin using the mavenLocalRepo parameter.

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.