Jenkins: nexusPublisher does not work and throws exceptions after jenkins-nexus-plugin upgrade


#1

Jenkins ver. 2.138.2
Nexus Repository Manager Version: Sonatype Nexus Repository ManagerOSS 3.13.0-01
Open Source Server: YES
Nexus-Platform-plugin version : 3.3.20180912-170211.be90294

Nexus Repository Manager 3.x has been configured in Jenkins with the right credentials. The test works.
I am trying to publish a maven project to the repository using the nexus-jenkins-plugin (Jenkins Plugins) and it fails with the following exception

Note: We are not using Nexus IQ server. I have just followed instructions for configuring the Nexus Repository Manager Nexus Platform Plugin for Jenkins title " Repository Manager 3 Integration"

Tried using other nexus plugin version too but i get the same error

Usage:

stage (‘Push to nexus’){
nexusPublisher nexusInstanceId: ‘jenkins-nexus’, nexusRepositoryId: ‘maven-releases’, packages: [[$class: ‘MavenPackage’, mavenAssetList: [[classifier: ‘’, extension: ‘’, filePath: ‘./clients/build/libs/xyz.jar’]], mavenCoordinate: [artifactId: ‘kafka-xyz’, groupId: ‘org.apache’, packaging: ‘jar’, version: ‘1.1’]]]
}

Exception:

com.sonatype.nexus.api.dh: Bad Request
at com.sonatype.nexus.api.di.handleResponse(SourceFile:51)
at org.apache.http.impl.client.CloseableHttpClient.execute(SourceFile:223)
at org.apache.http.impl.client.CloseableHttpClient.execute(SourceFile:165)
at com.sonatype.nexus.api.dd.a(SourceFile:84)
Caused: com.sonatype.nexus.api.exception.RepositoryManagerException: Upload component was unsuccessful (400 response from server)
at com.sonatype.nexus.api.dd.a(SourceFile:106)
at com.sonatype.nexus.api.dd.a(SourceFile:87)
at com.sonatype.nexus.api.dd.a(SourceFile:65)
at com.sonatype.nexus.api.dc.upload(SourceFile:152)
at com.sonatype.nexus.api.repository.v3.RepositoryManagerV3Client$upload$1.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:141)
at org.sonatype.nexus.ci.nxrm.v3.ComponentUploaderNxrm3$_upload_closure2.doCall(ComponentUploaderNxrm3.groovy:74)
Caused: java.io.IOException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
at org.sonatype.nexus.ci.nxrm.v3.ComponentUploaderNxrm3$_upload_closure2.doCall(ComponentUploaderNxrm3.groovy:77)
Caused: java.io.IOException: Upload of maven component with GAV [org.apache:kafka-android:1.1] failed
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)


#2

OMG I’ve been working on this issue for the past 4 hours.

I am seeing these errors come up whether I did releases or snapshots. I’ve since learned that snapshots are disallowed because it’s a bad habit (?). I couldn’t, however, figure out why this didn’t work with releases. Glad I stumbled upon this.

Taking a peek at the Nexus logs, I am seeing the following, if it helps any:
018-11-06 00:22:43,442-0500 WARN [XXX] *UNKNOWN org.sonatype.nexus.siesta.internal.ValidationErrorsExceptionMapper - (ID XXX) Response: [400] '[ValidationErrorXO{id='*', message='Not authorized for requested path 'path/to/artifact/1.0.0/artifact-1.0.0.war''}]'; mapped from: org.sonatype.nexus.rest.ValidationErrorsException: Not authorized for requested path 'path/to/artifact/1.0.0/artifact-1.0.0.war'

Interesting fact:
I installed the Nexus Artifact Uploader despite its age, and was able to upload to BOTH releases and snapshots just fine.

Looking forward to a fix!!! :frowning:

Edit: I was doing it through a freestyle job.


#3

@danjng @aganesan94 This article may help: Troubleshooting Artifact Deployment Failures – Sonatype Support

I don’t think you’re being affected by this, but there was a bug where the Nexus Platform Plugin wouldn’t work if Nexus was running at a non-root context (i.e. http://localhost:8081/nexus). This has been fixed in the 2018-10-25 version of the Nexus Platform Jenkins Plugin.


#4

Make sure you are using the very latest version of the Nexus Platform Plugin, there were some issues fixed in this area recently.