Codearte / gradle-nexus-staging-plugin

Automatize releasing Gradle projects to Maven Central.
Apache License 2.0
172 stars 26 forks source link

Plugin reports failure despite successful release #110

Closed io7m closed 3 years ago

io7m commented 5 years ago

Hello!

This is the exact configuration I'm using:

https://github.com/irradia/one.irradia.mime/tree/773e9b31158a71e59ac000834333b5550c83e338

I recently ran:

$ ./gradlew clean assembleDebug publish closeAndReleaseRepository

The output at the end of the execution was:

> Task :closeRepository
DEPRECATION WARNING. The staging repository ID is not provided. The fallback mode may impact release reliability and is deprecated. Please consult the project FAQ how it can be fixed.
Requested operation wasn't successful in first try. Retrying maximum 32 times with 30 seconds delay between attempts.
Requested operation was executed successfully in attempt 3 (maximum allowed 33)

> Task :releaseRepository
Requested operation wasn't successful in first try. Retrying maximum 32 times with 30 seconds delay between attempts.
Requested operation was executed successfully in attempt 3 (maximum allowed 33)

> Task :releaseRepository FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':releaseRepository'.
> Wrong 'oneirradia-1005' repository state 'closed' after transition (expected [released, not_found]). Possible staging rules violation. Check repository status using Nexus UI.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 4m 18s
204 actionable tasks: 192 executed, 12 up-to-date

The artifacts were sent to Maven Central, the staging rules completed successfully, and the artifacts were released:

https://repo1.maven.org/maven2/one/irradia/mime/

szpak commented 5 years ago

Wrong 'oneirradia-1005' repository state 'closed' after transition (expected [released, not_found]). Possible staging rules violation. Check repository status using Nexus UI.

When repository is closed (:closeRepository) it should be in closed state (and it is). After release (:releaseRepository) it should be in closed state or is can be already dropped (if auto drop is enabled - it is by default). The situation from your log could happen if there was an another release ongoing which would put another staging repository in the closed state. Could it be a case?

I tried to find the build on Travis, but I couldn't find on. Is the execution result from Travis or a local machine?

Btw, have you noticed:

DEPRECATION WARNING. The staging repository ID is not provided. The fallback mode may impact release reliability and is deprecated. Please consult the project FAQ how it can be fixed.

You could apply an addition plugin to "fix" it. Along the line, it is makes parallel releasing of different projects within the same staging repository possible.

szpak commented 5 years ago

I checked the code and a parallel build at that stage should not be a problem. The :closeRepository task should memorize the repository id, so it couldn't be hijacked after releasing.

  1. Can you check in the Nexus IU if there is still that staging repository and if it is in the closed state?
  2. Have you encountered it more than once?
io7m commented 5 years ago

The situation from your log could happen if there was an another release ongoing which would put another staging repository in the closed state. Could it be a case?

Not in this case, no. This project is the only one that uses the one.irradia staging profile, and I'm the only person doing releases.

I tried to find the build on Travis, but I couldn't find on. Is the execution result from Travis or a local machine?

Local machine only for Maven Central deployments.

Btw, have you noticed:

DEPRECATION WARNING.

I have, yes. Unfortunately I ran into further errors with the nexus-publish-plugin and couldn't find decent documentation and/or any way to correct the problem.

Can you check in the Nexus IU if there is still that staging repository and if it is in the closed state?

There's no staging repository present.

Have you encountered it more than once?

Yes, I've performed two releases and it has happened both times.

szpak commented 5 years ago

That's weird. You can run it with --info -s next time. Maybe some hint will be included there.

szpak commented 5 years ago

Btw, delayBetweenRetriesInMillis = 30000 is definitely too high. Please set it to 2000 (2 seconds). Nexus shouldn't be so slow.

Regarding nexus-publish-plugin usually it just works. As least in my e2e smoke test :) https://solidsoft.wordpress.com/2019/02/22/reliable-releasing-to-maven-central-from-travis-using-gradle-2019-edition/ In a case of problems you can raise a ticket: https://github.com/marcphilipp/nexus-publish-plugin/issues ;)

io7m commented 5 years ago

You can run it with --info -s next time. Maybe some hint will be included there. delayBetweenRetriesInMillis = 30000 is definitely too high. Please set it to 2000

Got it, and got it!

Regarding nexus-publish-plugin usually it just works. As least in my e2e smoke test :) https://solidsoft.wordpress.com/2019/02/22/reliable-releasing-to-maven-central-from-travis-using-gradle-2019-edition/

Thanks, I'll give it a read. I suspect part of my problem might be that I'm deploying an Android project. If it was plain Java without any of the Android tool brokenness, I'd be using Maven.

io7m commented 5 years ago

I just did a release today and the problem didn't occur. Wondering if it was a transient problem with Maven Central...

io7m commented 5 years ago

I've had this happen again this morning. Of course I wasn't running with --info -s. I've added a small shell script so that I always run with those flags whenever I do a release now. Sooner or later we'll capture this happening! :smile:

markslater commented 4 years ago

FWIW, I see similar issues with Gradle 6.0.1, nexus-staging plugin 0.21.1 and nexus-publish plugin 0.4.0:

Execution failed for task ':closeRepository'.
> Repository 'netsourceforgesvg2ico-1020' (in 'open' state) is in transition. Check again later.

When I go and look in the UI at https://oss.sonatype.org/#stagingRepositories, I see the repository is successfully closed. Unfortunately, I've just upgraded Gradle, taken the latest version of the plugins, and moved from publish to maven-publish, so I might have bungled something, but I suspect that the cause is that Sonatype has been on a go-slow for the past couple of days.

For reference, this is my build.gradle.

szpak commented 4 years ago

I had similar errors recently on e2e sanity tests on Travis. Retrying helped, so it might be an issue at the Sonatype side (Nexus hasn't been very reliable recently, but it is definitely better than a few weeks ago). @markslater How often do you see it?

markslater commented 4 years ago

Three or four times in the past two days.

I've also just had a failure to release through the UI, which then succeeded on the third attempt, so that supports the idea that something's a bit wonky with Sonatype at the moment.

I'll try again at some point tomorrow.

markslater commented 4 years ago

Now I've had some time to mull this over, it appears that there are two issues at play.

The first is that sometimes oss.sonatype.org times out resulting in inconsistent failures.

The second was that publish was consistently failing for me because of https://github.com/gradle/gradle/issues/11308.

Setting systemProp.org.gradle.internal.publish.checksums.insecure=true as suggested in the (corrected) comments solves the problem.

JavierSegoviaCordoba commented 4 years ago

It is happening to me, it is closed but gradle is failing.

In my case this is the problem ... (in 'open' state) is in transition

JavierSegoviaCordoba commented 4 years ago
systemProp.org.gradle.internal.publish.checksums.insecure=true

This is not working for me

JavierSegoviaCordoba commented 4 years ago
... (in 'closed' state) is in transition

I am getting too this error some times. Gradle 6.5.

szpak commented 4 years ago

@JavierSegoviaCordoba Have you checked Nexus UI to get know why this staging repository hasn't been transitioned correctly?

JavierSegoviaCordoba commented 4 years ago

@szpak I dropped the repo and tried multiple times to close via gradle. Last time it was successful in the try 21/21. Maybe sonatype problem?

szpak commented 4 years ago

@JavierSegoviaCordoba It might be. However, one important things to rememer. Closing/releasing might take longer than timeout (and you see some error in GNSP). Nevertheless, if the operation was triggered it should finish one day (successfully or with error). In a case of error, it's good to read in the Nexus UI why (e.g. problem with an OpenPGP key or not supported signatures). In successfully, for release, it is done, for close you can just call release from UI (of course assuming the simple case, you might o some extra steps in your Gradle build).

JavierSegoviaCordoba commented 4 years ago

I am just closing the repo, I release manually from Nexus UI. The problem was CI was failing but the repo was closed perfectly in Nexus UI.

szpak commented 4 years ago

In that case just increase the default timeout in the plugin. It was fine 2 years ago, but at the end of 2019 Sonatype Nexus had some performance issues and it is too short. I will probably release a new version with that adjusted (although probably to so long and suggested in #164).

JavierSegoviaCordoba commented 4 years ago

I have increased it to 50 - 3000, but I am seeing 100 - 6000 in that PR so I am going to use that until you release the new version. Thank you!

szpak commented 4 years ago

The rule of thumb is: increase timeout to the value that works for you. Unless there is a validation error, Sonatype Nexus should finish it eventually (most likely ;-) ).

szpak commented 3 years ago

The timeouts have been increase in 0.22.0. Nevertheless, please consider migration to gradle-nexus-publish-plugin.

A longer version. To make releasing to Maven Central even easier, I and Marc Phillip (the author of nexus-publish-plugin) combined forces to create a next generation, unified, 2-in-1 plugin - gradle-nexus-publish-plugin. It is a recommended solution, as our development effort will be put in that new plugin. See my blog post and the official migration guide.