Integration with Nexus Repository 3

Tips from the Trenches - Working with the Integration API - Featured Image

Author, Manfred Moser

Nexus Repository supports new repository formats such as Docker and Bower and introduces a fresh, clean user interface among other advantages. Adopting or upgrading repository manager often means that you need to update the configuration for your build tools and our documentation covers all aspects of that. Beyond that you might want to integrate the usage with your provisioning tools to automate deployment and potentially make it repeatable in different environments. Or just provide integration points for regular usage via a command-line tool and other systems.

Managing Scripts

The REST and Integration API of Nexus Repository 3 provides you features for exactly these use cases. It exposes a REST API that allows you to perform CRUD operations on your scripts as well as execute them. The scripts themselves have access to a focused API on the server.

Writing Groovy Scripts

The scripts are typically written in Groovy and stored and run on the server. This allows for a higher performance of the script execution that is less prone to fail due to connectivity issues. You can write these scripts easily with a setup such as the nexus-script-example project. Using IntelliJ IDEA, you get full code completion while developing your scripts.

Sonatype Nexus 3.0

The scripts can accept parameters as well as provide return values. The integration API is basically a powerful framework to create your own custom REST API and automation system for the repository manager.  It includes features to manage component-related tasks like configuring your repositories and blob stores. You can set up core configurations such as HTTP proxy or base URL and configure security aspects such as roles and users.

Demos and Example Projects

The examples include a number of simple shell script and JSON files. Check out the following video to see it all in action.

View the video on YouTube

Depending on your use case, you can either create one large script that does the complete configuration of a new server or numerous smaller scripts that are chained together for an execution. You can also write parameterized scripts that you run again and again with different configuration. For example, you could create a script to set up a new user as administrator and invoke it as desired. Another script could be used to deactivate a user.

A second video we created shows the editing process in the IDE and introduces the complex-script-example to demo the automated upload and execution of a number of scripts.

View the video on YouTube

This example uses a combination of shell and groovy scripts for interaction with the REST API. Of course, you are free to use your scripting language of choice for these tasks.


The REST and Integration API of Nexus Repository 3 provides a huge range of possibilities for automation. The demo videos and example projects make it easy for everyone to have a look and get started.
However, if you find that your specific use case can not be easily implemented, please ensure to reach out to us at so we can improve the API. Please let us know!

The following two tabs change content below.

Manfred Moser

Manfred Moser is trainer, author and community advocate at Sonatype working on efforts around the Nexus Repository Manager, the Nexus IQ Server and the Central Repository. He is a regular speaker at conference such as JavaOne, AnDevCon, OSCON and others.. Fluent in both German and English, he also speaks and writes Java and a bunch of other programming languages and uses these skills as committer and project lead on a number of open source projects such as the Android Maven Plugin. The open source community and open source software has been a passion of his for well over a decade and he is sure it will be for a few more decades. Manfred can be found on most social channels, including Twitter, LinkedIn and Google+.

Related posts


  1. Gass said:

    Hello thank you for the article it is useful for me. I want to know if it is possible to code a groovy script allowing to upload a local file to a hosted repository. Can you help me with that ? Thanks

  2. mani said:

    Can i get a groovy script which can create a new ldap connection with all attributes

Leave a Reply to mani Cancel reply