How to Override the Maven Local Repository setting
Purpose
When running a Maven Task in Bamboo, the build agent will often default to using ~/.m2/repository as the local repository. This guide will offer two options to override this setting, one locally – for one task – and one globally for Maven.
Solution
To achieve this for a given Task, you can:
- Go to the Plan that runs the maven clean deploy command
- Under the "Actions" menu, select "Configure Plan"
- Click on the Job that runs the Maven command
- Click on the Maven Task
- Add -Dmaven.repo.local=~/.m2/repository to the "Goal" section, before "clean deploy"
- Click "Save"
To achieve this in the settings file, you can:
- Open M2_HOME/conf/settings.xml in a text editor
- Find the <localRepository>/path/to/local/repo</localRepository> line
- Note: it may be inside a comment block <!-- ... ->, if so, move the -> to before the <localRepository> tag
- Replace /path/to/local/repo with the path to your repository
- Save and close
See Also
To configure Bamboo to use different Maven repositories for different builds, please see Configuring repository isolation for Maven executables.
Last modified on May 19, 2025
Powered by Confluence and Scroll Viewport.