Authenticating Maven Server as Profile Properties

I am trying to configure a common authentication system on a build server. We have several maven projects that state how deployment should be done in relation to the different teams that we have (each team has its own user / password for authentication):

<profile>
  <id>release-profile</id>
  <distributionManagement>
    <repository>
        <id>rep-releases</id>
        <name>rep-releases</name>
        <url>http://somewhere-releases</url>
    </repository>
    <snapshotRepository>
        <id>rep-snapshots</id>
        <name>rep-snapshots</name>
        <url>http://somewhere-snapshots</url>
    </snapshotRepository>
  </distributionManagement>
</profile>    

Then I declare authentication in the settings.xml to the declared servers as follows:

<servers>
  <server>
    <id>rep-releases</id>
    <username>${release.user.name}</username>
    <password>${release.user.password}</password>
  </server>     
  <server>
    <id>rep-snapshots</id>
    <username>${release.user.name}</username>
    <password>${release.user.password}</password>
  </server>      
</servers>

Finally, depending on the projects I want to deploy, I have several profiles defined in the settings.xml file of the build server:

<profile>
  <id>dep-team1</id>
  <activation>
    <activeByDefault>false</activeByDefault>
  </activation>
  <properties>
    <release.user.name>team1-user</release.user.name>
    <release.user.password>team1-password</release.user.password>
  </properties>
</profile>

The problem is that when I deployed the project, I received an authentication error (HTTP 401) as follows:

Error deploying artifact: Failed to transfer file: http://......./my-project-0.2-20090423.123247-3.pom. Return code is: 401

If I change the server authentication, replacing the properties with the user / password of the command, everything works fine.

<servers> < > ?

, ?

.

: hudson, maven2 ( /) maven, , ...

+3
2

, , , auth, . , rep-releases/rep-snapshots team1-repo/team2-repo ( auth ... )

.

, , ... , .

, ? ?

+1

, , dep-team1 distributionManagement - , release .

-, , - (., ). , .:

<profile>
  <id>release-profile</id>
  <repositories>
    <repository>
      <id>central</id>
      <url>http://central</url>
      <releases><enabled>true</enabled></releases>
      <snapshots><enabled>true</enabled></snapshots>
    </repository>
  </repositories>
</profile>

:

<project>
   <distributionManagement>

    <repository>
      <id>releases</id>
      <url>http://myurl/releases</url>
    </repository>

    <snapshotRepository>
      <id>snapshots</id>
      <url>http://myurl/snapshots</url>
    </snapshotRepository>

  </distributionManagement>
</project>
0

Source: https://habr.com/ru/post/1706964/


All Articles