1

I need a way to use HTTPBuilder in Groovy/Java with a url to tell if an artifact is in a Nexus 3 repository or not. Maven is not available.

<p>This maven2 hosted repository is not directly browsable at this URL.</p>

Sample code might be

String url = 'http://nexus.company.com:8081/nexus/repository/myrepo/com/company/sample-app/1.0.1/sample-app-1.0.1.war'
new HTTPBuilder(url).get(path: '') { response ->
   return response.statusLine.statusCode == 404
}

Whether it's there or not, this will give me a 200 with a text/html response.

Bonus points for how to do it without actually downloading the artifact if it's there.

tim_yates
  • 167,322
  • 27
  • 342
  • 338
Dave Brunkow
  • 352
  • 6
  • 20
  • Does the section ["Query for an artifact"](http://www.sonatype.org/nexus/2015/02/18/retrieve-artifacts-from-nexus-using-the-rest-api-or-apache-ivy/) help? – tim_yates Mar 01 '17 at 21:08
  • Maven/Ant/Ivy are not options and curl is the option of last resort. I just want to know if it exists, not download the artifact. – Dave Brunkow Mar 01 '17 at 21:12
  • No, the sample is Nexus 2 based and I believe service/local no longer exists in nexus 3. Fetching an artifact directly appears to always return a web page from the sample above. Trying to figure out why. – Dave Brunkow Mar 01 '17 at 21:22
  • I'm guessing there's a privilege the anonymous user is missing to get good results back up above. Artifact Download? – Dave Brunkow Mar 01 '17 at 21:43

0 Answers0