Maven staging plugin doesn't close repo

460 views
Skip to first unread message

Chris Hennick

unread,
Aug 6, 2018, 5:10:42 PM8/6/18
to Nexus Users

My pom.xml (https://github.com/Pr0methean/BetterRandom/blob/master/betterrandom/pom.xml) is basically the same as what was generated when I configured my project for Maven Central, except that I've merged the duplicate configuration entries. When I run `release:perform` (see https://github.com/Pr0methean/BetterRandom/blob/master/release.sh for the full workflow), the repository appears in the Nexus UI but remains open. How do I close and release it from the shell script? This is blocking my adoption of Continuous Delivery.


I've tried adding `<goals>deploy nexus-staging:close nexus-staging:release</goals>` (https://github.com/Pr0methean/BetterRandom/commit/e3003a47d1dc85b42019612fff8d5431bae601a1#diff-72e9461a860120dce0abb615d8eda20b), but this fails because the `deploy` goal deletes the local copy, and thus `nexus-staging:close` doesn't know what repository to close. If I could suppress the deletion step in `deploy` and put it after `nexus-staging:release` (a feature I've requested in https://issues.apache.org/jira/browse/MRELEASE-1011) then I'd be fine.

Rich Seddon

unread,
Aug 6, 2018, 5:58:44 PM8/6/18
to Nexus Users
I can't see your pom file, it gives a 404.

But by default the nexus-staging-maven-plugin will close staging repositories.  So it sounds like either the nexus-staging-maven-plugin is not being used for the deploy, or something is preventing the staging repository from being closed.  To check for the latter, examine the staging repository's activity in Nexus Repo.

Chris Hennick

unread,
Aug 6, 2018, 6:00:35 PM8/6/18
to Nexus Users
In case it helps, here's the log from a run of release.sh, *with* <goals>deploy nexus-staging:close nexus-staging:release</goals>: https://pastebin.com/KirEzezn


Chris Hennick

unread,
Aug 6, 2018, 6:03:25 PM8/6/18
to Nexus Users
I've checked the activity; it shows nothing. Here's the fixed link (Google Groups picked up the close-paren as part of the URL for some reason): https://github.com/Pr0methean/BetterRandom/blob/master/betterrandom/pom.xml

Chris Hennick

unread,
Aug 6, 2018, 6:04:30 PM8/6/18
to Nexus Users

Peter Lynch

unread,
Aug 6, 2018, 6:26:04 PM8/6/18
to seah...@gmail.com, Nexus Users
These are the goals being called:

[INFO] Executing goals 'deploy nexus-staging:close nexus-staging:release'...

and the deploy plugin is doing the deploy, instead of the nexus-staging-maven-plugin

[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ BetterRandom ---

Therefore calling the goal nexus-staging:close is not going to work because there is no staging properties file from which to read the id of the created staging repository.

Instead you should deploy using the nexus-staging-maven-plugin as recommended here:


As to why the release plugin is not picking up the nexus-staging-maven-plugin as the alternative deploy hook, likely due to setting

<mavenExecutorId>forked-path</mavenExecutorId>


Your setup does not match exactly our suggestions:



On Mon, Aug 6, 2018 at 7:00 PM Chris Hennick <seah...@gmail.com> wrote:
In case it helps, here's the log from a run of release.sh, *with* <goals>deploy nexus-staging:close nexus-staging:release</goals>: https://pastebin.com/KirEzezn


--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.
To post to this group, send email to nexus...@glists.sonatype.com.
To view this discussion on the web visit https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/2566e8f8-3f46-44f8-af26-bf0976c95b42%40glists.sonatype.com.
For more options, visit https://groups.google.com/a/glists.sonatype.com/d/optout.

Chris Hennick

unread,
Aug 6, 2018, 6:43:31 PM8/6/18
to Nexus Users, seah...@gmail.com
On Monday, August 6, 2018 at 3:26:04 PM UTC-7, Peter Lynch wrote:
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ BetterRandom ---

Therefore calling the goal nexus-staging:close is not going to work because there is no staging properties file from which to read the id of the created staging repository.

Instead you should deploy using the nexus-staging-maven-plugin as recommended here:


As to why the release plugin is not picking up the nexus-staging-maven-plugin as the alternative deploy hook, likely due to setting

<mavenExecutorId>forked-path</mavenExecutorId>


Your setup does not match exactly our suggestions:


That page mentions a profile called release, but I don't have one with that name, so I'm guessing release-sign-artifacts is the one to use; is that right? And do I understand correctly that the following commit is likely to fix my issue? https://github.com/Pr0methean/BetterRandom/commit/f4c53ecf6d9a1363ffd28e12548a24b6f0e741dc

Chris Hennick

unread,
Aug 6, 2018, 6:52:34 PM8/6/18
to Nexus Users, seah...@gmail.com
Update: I've tried using the deploy plugin, but that gives me the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.0.2:jar (default-jar) on project BetterRandom: You have to use a classifier to attach supplemental artifacts to the project instead of replacing them. -> [Help 1]

I suspect this is related to my use of Proguard, which seems in general to be poorly supported for library developers who build with Maven. I'll try switching back to release:perform but keeping the pom.xml changes in the above commit.

Rich Seddon

unread,
Aug 6, 2018, 7:17:51 PM8/6/18
to Nexus Users, seah...@gmail.com
It's not using the nexus-staging-maven-plugin for deploy:

    [INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ BetterRandom ---

I see that you've got configuration for the nexus-staging-maven-plugin in pluginManagement, but I don't see the plugin actually declared in "plugins".

Chris Hennick

unread,
Aug 6, 2018, 7:29:27 PM8/6/18
to Nexus Users, seah...@gmail.com
On Monday, August 6, 2018 at 4:17:51 PM UTC-7, Rich Seddon wrote:
I see that you've got configuration for the nexus-staging-maven-plugin in pluginManagement, but I don't see the plugin actually declared in "plugins".

Ah, thanks! The need to declare plugins in both places is my biggest beef with Maven -- I bet if there was a way to use one tag as both plugins and pluginManagement, then it would be used in 19 projects out of 20 (since I'm told the only use case for intentional divergence between them involves subproject pom's, which were so complicated to set up that I just ended up throwing away the root pom).

Chris Hennick

unread,
Aug 6, 2018, 7:41:56 PM8/6/18
to Nexus Users, seah...@gmail.com
But fixing that gives me the following:

[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy (injected-nexus-deploy) on project BetterRandom: Failed to deploy artifacts: Could not transfer artifact io.github.pr0methean.betterrandom:BetterRandom:jar.asc:2.4.4-20180806.233950-1 from/to sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots): Failed to transfer file: https://oss.sonatype.org/content/repositories/snapshots/io/github/pr0methean/betterrandom/BetterRandom/2.4.4-SNAPSHOT/BetterRandom-2.4.4-20180806.233950-1.jar.asc. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]

How do I (a) set it up with the credentials that the Maven release plugin was using, and (b) specify the version when I want it to be a production release rather than a snapshot release?

Chris Hennick

unread,
Aug 6, 2018, 8:32:49 PM8/6/18
to Nexus Users, seah...@gmail.com
On Monday, August 6, 2018 at 4:41:56 PM UTC-7, Chris Hennick wrote:
(b) specify the version when I want it to be a production release rather than a snapshot release?

PS: I'm not sure the latter has to happen *before* the jars have been uploaded, if Sonatype has the capacity to promote snapshots to releases (including changing the version number server-side so that it no longer ends in -SNAPSHOT). However, somewhere along the way I'd need a post-hook that would commit and push a new snapshot version number in pom.xml, as well as in two sibling pom.xml's that depend on the main one.

Rich Seddon

unread,
Aug 6, 2018, 9:54:22 PM8/6/18
to Nexus Users, seah...@gmail.com
Make sure the "serverId" parameter in the plugin's configuration matches the ID of a "server" element in your settings.xml that has the deployment credentials.

Chris

unread,
Aug 6, 2018, 9:58:58 PM8/6/18
to Rich Seddon, Nexus Users
It does: sonatype-nexus-staging

Peter Lynch

unread,
Aug 7, 2018, 8:08:33 AM8/7/18
to seah...@gmail.com, Nexus Users
Changing from a SNAPSHOT to release version happens in your build - no repository manager can/should change the version of a Maven artifact from SNAPSHOT to release. Think of promote as moving existing artifacts from A to B, not changing their identity.
 

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.
To post to this group, send email to nexus...@glists.sonatype.com.

Peter Lynch

unread,
Aug 7, 2018, 8:16:51 AM8/7/18
to seah...@gmail.com, Rich Seddon, Nexus Users


On Mon, Aug 6, 2018 at 10:58 PM Chris <seah...@gmail.com> wrote:
It does: sonatype-nexus-staging


In your example ERROR where 401 was returned, you are using a SNAPSHOT version, not release version. Therefore the "id" of snapshot repository applies instead:


Therefore you need a serverId in settings.xml that matches sonatype-nexus-snapshots
 
--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.
To post to this group, send email to nexus...@glists.sonatype.com.
Reply all
Reply to author
Forward
0 new messages