Craig P. Motlin
Craig P. Motlin

Reputation: 26740

How can I set up TeamCity agents to use separate maven local repositories?

I want to set up each TeamCity agent to use a local repository (maven.repo.local) in the agent's working directory (agent.work.dir). Is it possible to configure maven properties to use TeamCity properties in this way?

Upvotes: 11

Views: 6729

Answers (2)

Craig P. Motlin
Craig P. Motlin

Reputation: 26740

Enter -Dmaven.repo.local=%system.agent.work.dir%/.m2 for the setting Runner: Maven2 / JVM command line parameters

Upvotes: 10

Larry Shatzer
Larry Shatzer

Reputation: 3627

I don't use TeamCity, but Bamboo. The way I do this is for the maven goals, I have this defined:

-Dmaven.repo.local=${bamboo.M2REPOHOME}/${bamboo.buildKey} ...

Then the property M2REPOHOME is defined to be someplace on the filesystem, and bamboo.buildKey is the project name. I keep my m2 repositories all in one spot so I can easily nuke them. You should probably do something similar by setting maven.repo.local to the value of agent.work.dir, or someplace else. Quickly looking at the TeamCity docs, it looks like you would do something like this:

-Dmaven.repo.local=%agent.work.dir%/m2

Upvotes: 2

Related Questions