4

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?

divanov
  • 6,173
  • 3
  • 32
  • 51
  • Based on your configuration you have two identical id's for the snapshot and the stage repository. I wouldn't recommend that. Apart from that have you tried to login into oss nexus with the given credentials ? Furthermore why do you use nexus-staging plugin instead of the usual deploy plugin? – khmarbaise Dec 28 '14 at 11:34
  • I followed Apache Maven documentation http://central.sonatype.org/pages/apache-maven.html where they use identical ids in the example. Do they advice it wrong? – divanov Dec 28 '14 at 12:20
  • So another time. Have you tried to login with the given credentials? Successfull ? – khmarbaise Dec 28 '14 at 15:48
  • I can login here: https://oss.sonatype.org. But I cannot login to my local Nexus OSS I've installed and started. "Incorrect username, password or no permission to use the Nexus User Interface. Try again. Please login before attempting further requests." I'm not sure if I need local Nexus OSS for releasing to remote repository. – divanov Jan 03 '15 at 17:06
  • I can login here: oss.sonatype.org. But I cannot login to my local Nexus OSS with the same credentials. I'm not sure if I need local Nexus OSS for releasing to remote repository. – divanov Jan 03 '15 at 17:17

2 Answers2

4

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.

agabrys
  • 8,728
  • 3
  • 35
  • 73
rseddon
  • 5,082
  • 15
  • 11
  • I've filed a bug to https://issues.sonatype.org. And I got my permissions sorted out by Maven admins. Thanks to them. However, I still don't know if that's the only way to find out and change permissions or not? – divanov Jan 05 '15 at 23:23
-1

The credentials that you need to use shouldn't be of Sonatype JIRA, but of oss.sonatype.org. You need to register there separately.

[Update] The question was changed, so this answer is not relevant anymore. I'll keep it, since it's a common mistake.

JBaruch
  • 22,610
  • 5
  • 62
  • 90
  • Looking on all this madness, let me suggest you [using Bintray for that](http://blog.bintray.com/2014/02/11/bintray-as-pain-free-gateway-to-maven-central/). Much easier. – JBaruch Dec 28 '14 at 11:08
  • I don't remember registering separately, but I have the same set of credentials for JIRA and oss.sonatype.org. I even tried to create and used "Access User Token" on oss.sonatype.org. – divanov Dec 28 '14 at 11:12
  • The question was: "How can I check my access rights within Maven project I'm trying to release?" and frankly, there is still no answer to exactly this question. – divanov Jan 05 '15 at 23:21
  • Well, it's Sonatype... So you ask them, not many options there. – JBaruch Jan 06 '15 at 08:51
  • Credentials are the same (LDAP) right now for JIRA https://issues.sonatype.org/ and NXRM servers https://oss.sonatype.org/ and https://s01.oss.sonatype.org/ – julian-alarcon Feb 18 '22 at 16:05