Tag Archives: scripting

Searching with the Sonatype Nexus REST API: Python


November 24, 2008 By Tim O'Brien

This post is a follow-up to the two previous posts on Ruby and Groovy which provided some sample Ruby and Groovy scripts that can be used to list repositories and search for artifacts in a Nexus instance. Today, we’re going to see how to complete the same tasks using the Python scripting language.

The following scripts are in Python and they can be invoked from the command line using python (or jython). For example, if you want to run the quick-search.py script, you would run “jython quick-search.py activemq” to search for artfiacts that contain the string “activemq”. I tested these Python scripts using the latest Jython 2.5b0 distribution with version 1.2.6 of the jython-elementtree project at Google Code.  Go to the Jython page, download Jython 2.5b0, and then following the instructions on the jython-elementtree project list to check out the ElementTree library from source control and install it in your own Jython installation.  These scripts don’t require Jython, the could run in any Python 2.5 implementation. Continue reading

Searching with the Sonatype Nexus REST API: Groovy


November 21, 2008 By Tim O'Brien

This post is a follow-up to the previous post which provided some sample Ruby scripts that can be used to list repositories and search for artifacts in a Nexus instance.   Today, we’re going to see how to complete the same tasks using the Groovy scripting language.   The Groovy scripting language is a scripting language that has gained popularity due to the ease of integration with the JVM.

The following scripts are in Groovy and they can be invoked from the command line using groovy.  For example, if you want to run the QuickSearch.groovy script, you would run “groovy QuickSearch.groovy activemq” to search for artfiacts that contain the string “activemq”.   I tested these Ruby scripts using the latest Groovy 1.5.7 distribution.  Go to the Groovy page, click on Download, and download the Cross-platform Installer, this will install Groovy on your machine and also tell you what you’ll need to add to your PATH. Continue reading

Searching with the Sonatype Nexus REST API: Ruby


November 19, 2008 By Tim O'Brien

When you search for artifacts using http://repository.sonatype.org, the browser is querying the Nexus repository using a REST API.   In this post, I’m going to show you some simple Ruby scripts which you can use to search the Maven repository without loading up the Nexus web interface.  You might find these scripts more convenient and more customizable, and you should feel free to copy and modify them for your own use.

The following scripts are in Ruby and they use the REXML XML processor and the Net:HTTP library.  Both of these libraries are available in the Ruby standard library.   I tested these Ruby scripts using the latest JRuby release.  If you want to try these scripts out on your own, they will run in any standard Ruby interpreter without requiring any extra RubyGems. Continue reading