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
Because each repository definition should have unique id - and id must be connected with server section so it is not way to have one server for many repositories.
Trying put username and password in properties also have no expected result because properties in defined in setting.xml
are not resolved in the same settings.xml
But we can define environment variables with user name and password and use it in settings.xml
So we can have in settings.xml
:
Staging-group
${env.MVN_USER}
${env.MVN_PASS}
RELEASES
${env.MVN_USER}
${env.MVN_PASS}
SNAPSHOTS
${env.MVN_USER}
${env.MVN_PASS}
Now we must define somewhere used environment variables, we can use for it ~/.mavenrc
so this variables will be available only for maven.
example of ~/.mavenrc
export MVN_USER=user
export MVN_PASS=pass
This workaround give us possibility to have defined username and password for many repositories in one place.
Testing with maven 3.6.3