Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please make sure that closeAndReleaseRepository task works #131

Closed
denis-zhdanov opened this issue Sep 25, 2019 · 12 comments
Closed

Please make sure that closeAndReleaseRepository task works #131

denis-zhdanov opened this issue Sep 25, 2019 · 12 comments

Comments

@denis-zhdanov
Copy link

Problem

closeAndReleaseRepository task fails all the time:

./gradlew closeAndReleaseRepository

> Task :closeRepository FAILED
GET request failed. 401: Unauthorized, body: <empty>

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':closeRepository'.
> 401: Unauthorized, body: <empty>

It used to work before, failed after all versions were updated (plugin version is 0.21.1; gradle version is 5.6.2)

@szpak
Copy link
Member

szpak commented Sep 25, 2019

Hmm, I don't want to sound like a heldesk guy, but "it works on my machine" (to be precise on my CI server :) ). Today, 3 days ago and earlier.

During the aforementioned build there are 2 dummy (but real) Gradle projects released to Sonatype Nexus. They are occasional timeouts, but definitely not "401: Unauthorized".

Have you tried to downgrade to the previous version of GNSP that was working for you? Maybe it's just problem with your credentials (especially Nexus access token)?

@szpak
Copy link
Member

szpak commented Oct 10, 2019

Ping @denis-zhdanov.

@slonopotamus
Copy link

I've successfully made a release using Gradle 5.6.1 + nexus-staging-plugin 0.21.1 + nexus-publish 0.3.1 (warning, there's verbose output turned on because I was diagnosing issues with Sonatype OSS Nexus, unrelated to Gradle plugins). Here's build.gradle that was used for that release.

@szpak
Copy link
Member

szpak commented Oct 10, 2019

Great that it worked in the end. What was the reason of initial 401 failure?

@slonopotamus
Copy link

No. I am not @denis-zhdanov. I just added my comment to confirm that GNSP works for someone who is not a GNSP author :)

@szpak
Copy link
Member

szpak commented Oct 10, 2019

Ups, sorry, the original comment was not visible at the time I was writing mine :).

@denis-zhdanov
Copy link
Author

I tried downgrading to the previous version and it failed for me as well.

Also oss nexus web dashboard looks extremely slow when I try to close/release manually - operations take a while and often result in 503

@szpak
Copy link
Member

szpak commented Oct 11, 2019

@denis-zhdanov 503 is a known issue on the Sonatype side. 401 rather not. I still suspect there is something wrong with the credentials. Can you send me link to the project build.gradle and a CI build? If not, please paste the configuration part related to publishing (maven/maven-publish, GNSP, GNP, etc.)

@akashraje
Copy link

akashraje commented Jan 29, 2020

I'm facing the same problem. I provide nexus credentials through nexusUsername and nexusPassword in global gradle.properties. I see same results when I execute getStagingProfile .

> Task :closeRepository FAILED
Task ':closeRepository' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Getting staging profile for package group 'com.dummy'
GET request failed. 401: Unauthorized, body: <empty>
:closeRepository (Thread[Execution worker for ':',5,main]) completed. Took 1.764 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':closeRepository'.
> 401: Unauthorized, body: <empty>

My build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.21.1"
    }
}

plugins {
    id 'java'
    id 'maven'
    id 'io.codearte.nexus-staging' version '0.21.1'
}

uploadArchives {
    def nexusUser = "${nexusUsername}"
    def nexusPassword = "${nexusPassword}"

    repositories {
        mavenDeployer {
            repository(url: 'http://localhost:8081/repository/maven-releases/') {
                authentication(userName: nexusUser, password: nexusPassword);
            }
            snapshotRepository(url: 'http://localhost:8081/repository/maven-snapshots/') {
                authentication(userName: nexusUser, password: nexusPassword);
            }
            pom.artifactId = 'log-configurer'
        }
    }
}

Does this work only with Nexus Repository Manager Pro ?

@szpak
Copy link
Member

szpak commented Jan 29, 2020

@akashraje

GET request failed. 401: Unauthorized, body:

suggests the problem with your credentials. However, you set it in the mavenDeployer section and in addition you seem to have the nexusUsername and nexusPassword variables set.

Nevertheless, only credentials are taken from the mavenDeployer settings. Please try to set servelUrl to do not hit Sonatype Nexus:

nexusStaging {
    serverUrl = "http://localhost:8081/...."
}

where "..." in the URL represents the root path where API is available - for sonatype it is https://oss.sonatype.org/service/local/, but for local installation it's probably something else.

Btw, just to be sure. You use Nexus 2.x, right?

@akashraje
Copy link

@szpak

I was using Nexus 3.20.1.

I installed Nexus 2.14.16 today and tried. With Nexus 3 and Nexus 2 both I am able to deploy snapshots successfully to Snapshots repository.

However, with Nexus 2 I see the same issue.

> Task :closeRepository FAILED
GET request failed. 401: Unauthorized, body: <empty>

I tried adding credentials specifically

nexusStaging {
        username = "${nexusUsername}"
        password = "${nexusPassword}"
}

Regarding the serverUrl. I looked around a bit and this URL worked for other APIs
http://localhost:8081/nexus/service/local/. It worked for status users with xml output.

After adding this in nexusStaging I get 404 with HTML parsing error.

@szpak
Copy link
Member

szpak commented Feb 26, 2021

TL;TD. Please check gradle-nexus-publish-plugin and report a separate issue there is the problem still occurs.

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.

@szpak szpak closed this as completed Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants