0

I am trying to download an artifact from Nexus Pro 3.37.3-02 using curl but it is not working. I have found below commands which I think working for many other but in my case I am getting repository, maven.groupId, maven.artifactId, maven.baseVersion, maven.extension is not recognized as internal or external command, operable program or batch files.

curl -u usename:password -L -X GET https://MY_NEXUS/service/rest/v1/search/assets/download?sort=version&repository=MY-REPO&maven.groupId=MY_GROUP&maven.artifactId=MY_ARTIFACT_NAME&maven.baseVersion=0.1-SNAPSHOT&maven.extension=zip

I have followed this documentation to make this command. https://help.sonatype.com/repomanager3/integrations/rest-and-integration-api/search-api

Any help will be appreciated. Thanks,

  • Do you get an error ? What does curl tell you ? Status code? Is the given repository a snapshot repo ? – khmarbaise Feb 13 '22 at 14:49
  • Yes its an snapshot repository and this is the error i am getting {"errors":[{"code":"UNAUTHORIZED", "message": "access to the requested resource is not authorized", " detail":null}]} My credentials are correct and I am able to download the artifact from the nexus interface with same credentials. – irfan ansari Feb 14 '22 at 07:52
  • I have also tried to use token username and password instead of plain username and password but getting below. { "schemaVersion": 2, "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json", " manifest": [ { "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json" "size": 1155, "digest": "jkgj" "platform": { "architecture": " amd64" "os": "linux" } } ] } Same warning comes for maven.groupId, maven.artifactId, maven.baseVersion and maven.extension. – irfan ansari Feb 14 '22 at 07:52
  • First you should try to solve the issue: `UNAUTHORIZED`... – khmarbaise Feb 14 '22 at 08:59
  • 1
    Thanks for your help, the problem is fixed by using token and token password instead of plain username/password and adding double quotes around the url as below. – irfan ansari Feb 14 '22 at 18:19
  • curl -u token:tokenPassword -L -X GET "https://MY_NEXUS/service/rest/v1/search/assets/download?sort=version&repository=MY-REPO&group=MY_GROUP&name=MY_ARTIFACT_NAME&maven.baseVersion=0.1-SNAPSHOT&maven.extension=zip" – irfan ansari Feb 14 '22 at 18:26

1 Answers1

1

In case if anyone else facing the same problem then this is the solution which worked for me.

curl -u token:tokenPassword -L -X GET "https://MY_NEXUS/service/rest/v1/search/assets/download?sort=version&repository=MY-REPO&group=MY_GROUP&name=MY_ARTIFACT_NAME&version=MY_Version&maven.extension=zip" --output My_Artifact.zip
Tobb
  • 11,850
  • 6
  • 52
  • 77