Sonatype Nexus Repository has new supported REST API endpoints that can automate your binary management needs. REST APIs allow clients to interact with an application, providing them with the capabilities of retrieving and transforming application data. Sonatype Nexus Repository endpoints allow you to automate and seamlessly integrate with your tools and CI/CD pipeline.
Many programming languages can be used to interact with Sonatype Nexus Repository. In the examples below, we will use the command line tool cURL in addition to the Groovy programming language. In this tutorial, we will show you how to quickly setup with Sonatype Nexus Repository by using its API endpoints to create a user, a repo, and user permissions.
Create a blobstore
Create a blobstore. This is the blobstore that we will be associating with our new repo.
Create a Repository
We will need to create our repository, and we will use Groovy to accomplish this.
i) Create JSON file mavenScript.json. Here we are creating a script called "mavenRepo" which will create a hosted repository titled "ny-maven-internal".
Post Script to Sonatype Nexus Repository
ii) Post this as a script to Sonatype Nexus Repository.
Run the Script on Sonatype Nexus Repository
iii) Run this script on Sonatype Nexus Repository to create the repository.
Create a Role
We need to create a role so that this can later be assigned to our new user. This role grants read and write permissions on repo ny-maven-internal.
Create a User
Create User. In this step, we will assign this user the ny-dev-role we created in step 1.
That's it! In four steps, you have created a user who has read/write access to their team's new repository.
You can view the full list of supported APIs in the UI or in our documentation here. For additional scripts, you may find our community GitHub repo a fun place to stop by and say hello.
Written by Sable Yemane
Sable Yemane is a Sales Engineer at Sonatype focused on providing DevSecOps solutions to enterprises
Tags
Try Nexus Repository Free Today
Sonatype Nexus Repository is the world’s most trusted artifact repository manager. Experience the difference and download Community Edition for free.