If you plan on developing software and keep it going for a long time, repository managers play an important role. Repository managers help you optimize the storage of the packages required for the software.
Let's consider repositories for Python programming language. Python uses the PyPI repository manager. When you install Python, you get a few default functionalities, but if you want to use specific libraries, you will have to install them.
Repository managers make this easier. The packages are stored on the repository managers, and if you want to use one, you just have to get it from the repository. You don't have to keep on looking for the artifact you want to use at different places when they are stored in a dedicated repository.
Sonatype Nexus Repository OSS is one such artifact repository, and that's what this post is about. But first let me explain why you would want to use this repository manager.
Imagine that you are building a Linux operating system of your own. You've put lots of effort into designing the architecture, programming the functionalities, designing the user interface, etc. You've published the operating system, and people really liked it.
Day by day, the number of users using your operating system is increasing. You were the only person who built the operating system, and now it's getting difficult for you to manage it by yourself. So you decide to allow other users to add software to it.
In such cases, you can make use of a repository manager to store the software and for people to use it.
Sonatype Nexus Repository OSS is a free-to-use artifact repository. It supports various formats, such as Maven, APT, and Go. You can find the complete list of supported formats here.
Sonatype Nexus Repository OSS helps you host your own repositories, but you can also use the Sonatype Nexus proxy for public repositories. There is also Sonatype Nexus Repository.
Now that you know what Sonatype Nexus Repository OSS is, let me tell you how to use it.
The first step is to download the repository manager. You can download it here for Windows, Linux, and OS X.
After downloading the file, you will have to extract it. Find the folder that contains a bin folder. That's where you’ll have to start this tool from.
The prerequisite to use Sonatype Nexus Repository OSS is to have Java 8 Run Time Environment (JRE). You can download it here.
To start it, open command prompt, switch to the Sonatype Nexus folder, and then into the bin directory. Then run the following command:
Windows:
nexus.exe /run
Linux:
./nexus run
Once the tool has started, you can access it using your web browser on the URL
http://localhost:8081/
This is what the home page will look like:
You see the supported formats and buttons for configuration, documentation, and Sonatype Nexus community. To start with repository management, you will have to sign in.
The default username is admin. You will find the default password in the path mentioned on the sign-in page.
Sonatype Nexus has a few repositories by default. You can see them under the Browse tab.
There is also an admin tab where you can set up policies, security, and much more, depending on the privileges you have. The screenshot below shows the functions available to an admin.
Now, let me show you how to create a user.
To create a user, click on the Users tab. Then fill out the details such as ID, first and last name, email, password, the status of the user (active/disabled), and the roles of that user. Then click on the Create local user button.
You can see the list of all the users under the Users tab.
To create a repository, click on the Repository tab, and under the Repositories section, click the Create repository button.
Then you will have to choose the recipe of the repository. This decides what kind of file format you will be uploading and whether it's a hosted or a proxy repository.
Then fill out the details for the repository. For example, if you choose Advanced Packaging Tool (APT), you will have to fill in details such as name, APT distribution, and signing key. If you choose PyPI, you will have to fill in details such as name, blob details, and deployment policy.
After filling in all the details, click on the Create repository button.
Once you've created the repository, you have to add content to it. To do this, click on the Upload button on the homepage, then click on the repository you want to upload the content for. You will have to fill in details about the content and then upload the content.
Not all the features are included in the free version (Sonatype Nexus Repository OSS) of Sonatype Nexus Repository. Some of the highlights are detailed below.
Sonatype Nexus Repository uses role-based access control. This means that the authorization you give to a particular user depends on the role of that user. The administrator has control over what authorization other users have.
Users can be given privileges to read, write, create, and update the resources. Suppose the same privileges have to be given to a number of users. In that case, you can create a collection of privileges called roles, then assign the role to the user.
Tagging is used extensively by the Staging feature. The staging functionality in Sonatype Nexus Repository supports promotion of software components matching your organization's software development life cycle phases by moving those components between repositories. This allows the creation of isolated release candidates that can be discarded or promoted to make it possible to support the decisions that go into certifying a release.
Sonatype Nexus Repository provides representational state transfer (REST) application programming interfaces (APIs) that will help you if you want to integrate the repository manager with external systems. You can find APIs for almost every popular external system, such as Node, Script, and Blob. You can find the complete list of APIs here.
You should always address performance and real-time updates when it comes to building software. Webhooks are a great approach for real-time updating because they make a call as soon as there is something to update. Sonatype Nexus Repository provides webhooks to notify external systems of important activities.
It is important for a business model to make its product available whenever there is a requirement. Unavailability of your product might result in business loss and impact the impression users have of your organization. Sonatype Nexus uses High Availability Clustering (HA-C) to improve uptime.
To use HA-C, you need to have:
A test environment
A load balancer
Three separate instances of Sonatype Nexus Repository
Connectivity between the Sonatype Nexus Repository instances
If you want to learn more about Sonatype Nexus' HA-C, you can find details here.
You will find almost everything that you need to manage repositories in Sonatype Nexus Repository. Why wait? Go ahead and try it.