Maven multi module and remote buildAgent
in VCS
+ myMavenMultiProj
+ projAPI
*pom.xml (produces projAPI.jar)
+ exposeAPI_A (dependency on projAPI)
*pom.xml (produces exposeAPI_A.war )
+ exposeAPI_B (dependency on projAPI)
*pom.xml (produces exposeAPI_B.war )
*parentpom.xml
Configuration: 2 buildAgents
buildAgent1 = local (runs on TC server machine) : buildAgent2 remote
1) buildAgent1 compiles projAPI with maven install
* this creates a local build artifact and also installs this artifact in local maven repo .m2
2) buildAgent2 builds exposeAPI_A
???? How does TC get the required dependency (projAPI-{version}.jar) to this build in a way that maven understands ????
When maven tries to build exposeAPI_A using its' pom.xml it will search for projAPI-{version}.jar
<dependency>
<groupId>com.here</groupId>
<artifactId>projAPI</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
in a local repository first then a central repo. This won't exist on buildAgent2 in a local buildAgent maven repo right? Or does TC know how to pre-fetch this dependency from buildAgent1 and correctly translate it and place it in buildAgent2's maven repo?
How does TC server handle this when using an artifact dependency? Is there some kind of shared .m2 repository between build agents?
Please sign in to leave a comment.
Hi,
As you correctly point out, the artifact dependency simply will make the jar (or any files you set up) available from one build into other builds. There are several approaches to what you are looking for:
-Install the jar in both build agents' repos after it's been built, then proceed with the regular builds.
-Force the initial build to run in a specific agent that exposes its repository through an agent requirement, install it in that agent's repository, then use maven triggers. That way you can also scale up build Agents without having to worry. More information here: https://confluence.jetbrains.com/display/TCD10/Configuring+Maven+Triggers#ConfiguringMavenTriggers-mavenArtifactDependencyTrigger
-Make the dependent builds gather the artifact dependency and install it in the local repo of the current agent before the build itself starts.
"exposes its repository through an agent requirement"
I am searching for this now trying to figure out how to do expose the repo? Can you give me a pointer to how I expose the repo?
Sorry, I didn't compose that sentence properly. I meant:
-Force the build to run on a build agent that exposes its repository
-Force the build to run on that specific agent by forcing it through an agent requirement
You would need to configure then that maven repository to be exposed, and force that build to run on that specific agent.
Excuse me for the misunderstanding.
It is the "exposes its repository" part I don't understand. Is there some way the TeamCity can allow me to expose a repository or are suggesting something simpler like NFS sharing a .m2 folder?
Yes, i mean that the repository has to be accessible from different computers. You can configure a local maven to use different repositories, and this have to be available (that's what I meant with exposed). Whether you do it through NFS and then configure the repository as a file, or you configure it as an internal repository via http, is up to you, but this is outside TeamCity itself (although you can pass a specific maven "settings.xml" file explicitly to teamcity that the maven runner will use)
More information on how to set that up here:
https://maven.apache.org/guides/introduction/introduction-to-repositories.html