Warm tip: This article is reproduced from serverfault.com, please click

Setting a single server credentials in Maven for multiple repositories

发布于 2013-07-07 10:47:48

Can I have multiple repositories in Maven settings.xml with a single server credentials?

We're using Maven 3.0.4 to deploy artifacts to Nexus pro version 2.2.1

We have multiple repositories on the same server, and a user uses the same credentials to access all these repositories.

The settings.xml multiple repositories with the same credentials:

<repositories>
<repository>
   <id>Staging-group</id>
   <url>http://server/nexus/content/groups/Staging-group</url>
<repository>
   <id>RELEASES</id>
   <url>http://server/nexus/content/repositories/RELEASES</url>
</repository>
<repository>
   <id>INTERNALS</id>
   <url>http://server/nexus/content/repositories/INTERNALS</url>
</repository>
<repository>
   <id>SNAPSHOTS</id>
   <url>http://server/nexus/content/repositories/SNAPSHOTS</url>
</repository>
</repositories>
.....
<servers>
<server>
   <id>Staging-group</id>
   <username>user</username>
   <password>password</password>
</server>
<server>
   <id>RELEASES</id>
   <username>user</username>
   <password>password</password>
</server>
<server>
   <id>SNAPSHOTS</id>
   <username>user</username>
   <password>password</password>
</server>
<server>
   <id>INTERNALS</id>
   <username>user</username>
   <password>password</password>
</server>
</servers>

Nexus uses Active Directory authentication. So every time a user changes his or her Windows password, they need to change all four entries in the settings.xml file

Is there a way to declare the credentials once for all the repositories?

Thanks, Eyal

Questioner
Eyal Azran
Viewed
0
John Ament 2013-07-07 21:00:16

Yes, at least I believe this should work.

Instead of

<repository>
   <id>SNAPSHOTS</id>
   <url>http://server/nexus/content/repositories/SNAPSHOTS</url>
</repository>

Use

<repository>
  <id>nexus</id>
  <name>SNAPSHOTS</name>
  <url>http://server/nexus/content/repositories/SNAPSHOTS</url>
</repository>

Then just reference nexus as your server id.