Setting up Maven for Multiple Groups
Scenario
Setup bamboo for multiple development groups. How to configure a maven2 builder to use different repositories or different settings.xml per group.
Resolution
The environment variable M2_HOME is used to point the OS to the maven executable. Common values are /usr/share/maven or /opt/local/maven etc. M2_HOME is not used for pointing to the local repository.
However M2_HOME/conf/settings.xml
can contain a different path to the local repository if configured other than the default path.
maven -Dmaven.repo.local
To structure your bamboo instance assign a bamboo project per group and have all relevant plans that belong to that group under each project. Maven can be called with -Dmaven.repo.local=/absolute/path/to/groups/local/repository
parameter to direct maven to an alternative local repository (the default being ~/.m2/repository
).
In the builder definition of each plan add this parameter to the maven goal field. Or use a global variable for each group containing the absolute path to the group's local repository.
For example the global variable,
key |
value |
---|---|
local.m2.group1 |
/absolute/path/to/groups/local/repository/.m2/repository |
can be passed in the plan's builder definition in a group1 project as ${bamboo.local.m2.group1}
maven -s
Alternatively you can define a set of multiple maven2 settings.xml and use the -s /path/to/groups/local/settings.xml in the maven goal field. You can also use global variable(s) here to keep the information in one place.