Setting up Maven for Multiple Groups
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
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}
1
2
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.
Was this helpful?