PUT requests to hosted Maven repository fail

284 views
Skip to first unread message

Robert Gacki

unread,
Apr 6, 2018, 5:36:41 AM4/6/18
to Nexus Users
Hi,

I am trying to upload artifacts via PUT requests to a hosted Maven repository of a Nexus 3.9 instance. But at least one upload always fails. There is nothing in the logs that points to an exception or to a revocation.

I am basically doing the first proposed solution explained on this support page: https://support.sonatype.com/hc/en-us/articles/115006744008-How-can-I-programmatically-upload-an-artifact-into-Nexus-3-

The files that I try to upload look like this:

acme-0.0.1-26.pom
acme-0.0.1-26.jar
acme-0.0.1-26-javadoc.jar
acme-0.0.1-26-sources.jar

The POM is always uploaded first, then the JARs. For the upload, I am using PowerShell, but I also tried with cURL and my IDEs HTTP client. Most of the time, the 'acme-0.0.1-26-javadoc.jar' fails to upload for no clear reason. I am just getting a 401 response or, when behind a reverse proxy, a 502 Bad Gateway response.

Here is what I do in PowerShell to upload the files:


$credential = ...
$nexusRoot = "http://somehost/nexus/repository/maven-releases/com/acme/acme/0.0.1-26"

Get-ChildItem -Path . -Filter *.pom | ForEach-Object {
    Invoke-RestMethod -Method Put -Uri "${nexusRoot}/$($_.Name)" -Credential $credential -ContentType "application/xml" -Infile $_.FullName
}

Get-ChildItem -Path . -Filter *.jar | ForEach-Object {
    Invoke-RestMethod -Method Put -Uri "${nexusRoot}/$($_.Name)" -Credential $credential -ContentType "application/java-archive" -Infile $_.FullName
}


I don't understand why this fails almost all the time for the 'javadoc' classified file, but not for the other files. It feels unreliable.

Is there a way to find out whats wrong? Am I doing something wrong? I'd appreciate any idea or hint.

Kind regards,
Robert

Robert Gacki

unread,
Apr 6, 2018, 7:07:24 AM4/6/18
to Nexus Users
It appears that it was a problem with authentication, that was somehow unreliable. Its really strange, because some files were uploaded, others were not. I am not sure what the exact problem was.

Rich Seddon

unread,
Apr 6, 2018, 10:01:56 AM4/6/18
to Nexus Users
Have a look here, I think this may be the issue:

Robert Gacki

unread,
Apr 6, 2018, 11:54:34 AM4/6/18
to Nexus Users
Thanks, I will try that.


Reply all
Reply to author
Forward
0 new messages