Search code examples
mavenmaven-3sonatypemaven-central

Releasing to Maven Central


I was added as a developer to the Maven project and now I need to make a release. I've added nexus-staging-maven-plugin to pom.xml file.

<plugin>
  <groupId>org.sonatype.plugins</groupId>
  <artifactId>nexus-staging-maven-plugin</artifactId>
  <version>1.6.3</version>
  <extensions>true</extensions>
  <configuration>
    <serverId>ossrh</serverId>
    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
    <autoReleaseAfterClose>true</autoReleaseAfterClose>
  </configuration>
</plugin>

Also I've added distributionManagement to pom.xml

<distributionManagement>
  <snapshotRepository>
    <id>ossrh</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
  </snapshotRepository>
  <repository>
    <id>ossrh</id>
    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
  </repository>
</distributionManagement>

I've placed my credentials to ~/.m2/settings.xml

<settings>
  <servers>
    <server>
      <id>ossrh</id>
      <username>divanov-oss.sonatype.org-account</username>
      <password>divanov-oss.sonatype.org-password</password>
    </server>
  </servers>
</settings>

I also tried to create and use "Access User Token" on oss.sonatype.org as my credentials.

Now I'm executing to deploy release into maven central.

mvn clean deploy

which ends up in the error:

[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.3:deploy
(injected-nexus-deploy) on project project: Failed to deploy artifacts:
Could not transfer artifact
project:jar:4.4.0-20141228.104011-1 from/to ossrh
(https://oss.sonatype.org/content/repositories/snapshots): Access denied to:
https://oss.sonatype.org/content/repositories/snapshots/project/project/4.4.0-SNAPSHOT/project-4.4.0-20141228.104011-1.jar,
ReasonPhrase: Forbidden. -> [Help 1]

or

[INFO] Performing remote staging...
[INFO] 
[INFO]  * Remote staging into staging profile ID "329a0bc2b7ce06"
[ERROR] Remote staging finished with a failure: 403 - Forbidden
[ERROR] 
[ERROR] Possible causes of 403 Forbidden:
[ERROR]  * you have no permissions to stage against profile with ID "329a0bc2b7ce06"? Get to Nexus admin...

How can I check my access rights within Maven project I'm trying to release?


Solution

  • Your credentials are likely fine, you'd be getting a 401 error if they weren't. You're getting 403 (forbidden). This means the credentials were accepted, but you don't have permission to publish the artifacts. The most common cause of this is that you are using a different Maven group ID than the one assigned to you. File an issue at https://issues.sonatype.org in the "Community Support - Open Source Project Repository Hosting" and we'll get this worked out.