How To Setup Nexus Repositories
What you will learn
You will learn how to setup a repository on a nexus instance and what you need to know to be able to include the repository as a source in the PAK applications. We will shed light on the difference between Command and Workflow repositories, how to group repositories and why indexing the artifacts is important.
Prerequisites
-
A running Nexus Repository OSS instance
-
Admin privileges to access the settings page and create new repositories
-
Roughly 15 minutes
What is Nexus and a Repository?
Nexus is a repository manager that allows you to manage software artifacts required for development, deployment, and provisioning. It can store and manage binary software artifacts and their associated metadata in a centralized location. These artifacts include commands, workflows, libraries, and dependencies that you need for working with PAK applications. Those artifacts are put into containers we call a nexus repository, which enable us to differentiate between sources from within one manager.
Setting Up a Nexus Repository
Navigating to the Settings
To create a new repository for your commands or workflows you first need to navigate into the Nexus Settings
> Repositories
and press the Create Repository
button. The steps are marked in the picture below
Choose the Correct Repository Type
Next you will need to choose from a list of types your nexus repository should be. Those types define how the artifacts are handled by the manager and what additional metadata is required. For Command repositories choose maven2 (hosted)
and for Workflow repositories raw (hosted)
.
Configure New Repository
After choosing the repository type you need to configure the last steps of your repository. Raw repositories do not need that much of configuring in contrast to the maven2 repositories. In the following we will speak about configuring maven2 correctly.
1 | Name your repository as you like. Here we name it howto-test . |
2 | We recommend to choose Mixed for Version policy. This allows you to host snapshots aswell as release versions of your commands. |
3 | Choose a blob store for your artifacts. |
4 | We recommend to choose Allow Redeploy for the Deployment policy. This allows you to overwrite the artifacts without deleting them before. |
At last, you can commit your config with the Create repository
button at the end of the page. You can check your new repository and its address now under the Browse section of the nexus.
Grouped Repositories
When you created a repository to hold your commands, you cannot start with the applications yet. The most barebone Command artifact may have a dependency to a third party library. You could manually add the library also to your commands repository, but then in time your repository will fill artifacts that aren’t actual commands. Instead, we create a second repository and combine both commands and the third party repository to a Grouped Repository.
When you have dependencies that can be fetched from the maven repository, then you do not need to manually copy and upload your dependencies into a repository. Create a new repository and choose maven2 (proxy)
as its type, and configure it to point to the url https://repo1.maven.org/maven2/
. This will proxy all dependency fetch calls to that repository over to the maven repository, providing you with all dependencies. When you have non public libraries then you need to create a new repository as explained above.
Creating a Grouped Repository
Navigate to the Create new Repository
view and create a repository of the type maven2 (group)
. At the configuration at the bottom now move the Command repository and third-party repository to the members to group them together.
Use the newly grouped repository as a source for the pak applications instead of the commands only repository! |
Indexing Artifacts of maven2 Repositories
The last step to successfully work with nexus repositories is to configure indexing tasks for your maven2 repositories. Artifact in such a repository need to be indexed by such a task, to be able to be found when requested. Only after an index was run do changes to the artifacts take effect.
Create Index Task
To create a task to trigger the indexing navigate into Nexus Settings
> Tasks
and press the Create task
button.
Configure Index Task
Then choose Maven - Publish Maven Indexer files
from the available task lists and configure it according to below.
1 | Give your task a name that you can recognize it later. |
2 | Choose the repository to index |
3 | Choose how often you want to index. To index after a set time will allow to react to changes automatically. We recommend to choose Hourly to keep the system up to date. |
Now you can run the task and let the repository index your artifacts.
Pay attention to index in the correct order for grouped repositories. First index the lowest repositories in the hierarchy, your command repository for example. And at the end index the group repositories. Otherwise, the grouped repository may not notice the changes of its child repositories. We recommend therefore to run the indexing for hosted repos 15 minutes prior to the grouped repos. |