1

I am getting a 401 Unauthorized exception from deploying the maven. Here is the relevant section of the pom file.

<!-- pom.xml -->
<plugin>
  <groupId>org.sonatype.plugins</groupId>
  <artifactId>nexus-staging-maven-plugin</artifactId>
  <version>[version]</version>
  <executions>
    <execution>
      <id>default-deploy</id>
      <phase>deploy</phase>
      <goals>
        <goal>deploy</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <nexusUrl>[your-nexus-base-url]</nexusUrl>
    <serverId>[your-nexus-base-id]</serverId>
    <skipStaging>true</skipStaging>
  </configuration>
</plugin>

<distributionManagement>
  <snapshotRepository>
    <id>nexus-snapshots</id>
    <url>[your-nexus-base-url]/content/repositories/snapshots/</url>
  </snapshotRepository>
  <repository>
    <id>nexus-releases</id>
    <url>[your-nexus-base-url]/content/repositories/releases/</url>
  </repository>
</distributionManagement>

<!-- settings.xml -->
<servers>
  <server>
    <id>[your-nexus-base-id]</id>
    <username>[username]</username>
    <password>[encrypted-password]</password>
  </server>
</servers>
Dan Grahn
  • 9,044
  • 4
  • 37
  • 74

1 Answers1

2

You must have an ID in your settings.xml file to match the ID under the distribution management. NOT ONLY the ID in the nexus plugin.

<!-- pom.xml -->
<distributionManagement>
  <snapshotRepository>
    <id>[your-nexus-base-id]</id>
    <url>[your-nexus-base-url]/content/repositories/snapshots/</url>
  </snapshotRepository>
  <repository>
    <id>[your-nexus-base-id]</id>
    <url>[your-nexus-base-url]/content/repositories/releases/</url>
  </repository>
</distributionManagement>

<!-- settings.xml -->
<servers>
  <server>
    <id>[your-nexus-base-id]</id>
    <username>[username]</username>
    <password>[encrypted-password]</password>
  </server>
</servers>
Dan Grahn
  • 9,044
  • 4
  • 37
  • 74